Skip to content

Instantly share code, notes, and snippets.

@rubysolo
Created April 3, 2012 20:53
Show Gist options
  • Save rubysolo/2295421 to your computer and use it in GitHub Desktop.
Save rubysolo/2295421 to your computer and use it in GitHub Desktop.
negative lookahead match
irb(main):003:0> r = %r{href="(?!(/|#|mailto))}
=> /href="(?!(\/|#|mailto))/
irb(main):004:0> r =~ 'href="http://foo.com"'
=> 0
irb(main):005:0> r =~ 'href="/root"'
=> nil
irb(main):006:0> r =~ 'href="#anchor"'
=> nil
irb(main):007:0> r =~ 'href="mailto:[email protected]"'
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment