Ruby for regular expression that does not contain a string

ruby
/^(?:(?!\bFred\b).)*$/.match(“Fred”) # does not contain fred anywhere

/^(?!.*\bFred\b).*$/.match(“Fred”) # does not contain fred at the beginning.  Hmm.

From http://lists.evolt.org/archive/Week-of-Mon-20030908/148123.html

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.