Created
April 3, 2012 20:53
-
-
Save rubysolo/2295421 to your computer and use it in GitHub Desktop.
negative lookahead match
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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