Created
February 26, 2014 16:51
-
-
Save aarti/9233441 to your computer and use it in GitHub Desktop.
Regexp using negative lookahead and negative look behind assertions
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):040:0> testcases | |
=> ["hello world", "'hello world", "'hello' world", "hello' world"] | |
irb(main):041:0> testcases.each { |i| puts /(?<!')hello(?!')/.match(i) } | |
hello | |
=> ["hello world", "'hello world", "'hello' world", "hello' world"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment