Regex Reverse Matching
The fact that regex doesn’t support inverse matching is not entirely true. You can mimic this behavior by using negative look-arounds:
^((?!mystring).)*$
The regex above will match any string, or line without a line break, not containing the (sub) string ‘mystring’. This is not something regex is “good” at (or should do), but still, it is possible.
Thanks to a poster at stackoverflow.com for the solution.
Published on June 14, 2011