Skip to content

Instantly share code, notes, and snippets.

@Vaguery
Created March 21, 2010 23:22
Show Gist options
  • Save Vaguery/339653 to your computer and use it in GitHub Desktop.
Save Vaguery/339653 to your computer and use it in GitHub Desktop.
# Ruby 1.9+
j = /(?<!\-)\-{3}(?![\-])/
positives = ["---", "x--- ", " ---x", "x --- x", "---!"]
negatives = ["--", "----", "x----", "----x", "---- x", "--!", "x--", "--x"]
positives.each {|t| puts "in #{t} I find a match a position #{t.match(j) ? t.match(j).offset(0) : 'NOWHERE!!1!'}, and I want to"}
negatives.each {|t| puts "in #{t} I find a match a position #{t.match(j) ? t.match(j).offset(0) : 'NOWHERE!!1!'}, and I don't want to"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment