bobkoure wrote:Why not use lookahead?
negative lookahead:
(?!foo) means not followed by "foo".
^(?!.*foo) means start of line not followed by any number of chars and then "foo"
positive lookahead:
(?=bar) means followed by "bar"
^(?=.*bar) means start of line followed by any number of chars and then "bar" .
Lookahead is a regex "zero width operator", which means (among other things) that you can stack 'em, so...
^(?!.*foo)(?=.*bar)
Will pick up any lines that have "bar" but not "foo".
I was looking for the same thing, with a twist:
I would like to exclude all posts with "foo" except those with "newfoo"?
(The simple negative lookahead above, (?!foo), also excludes "newfoo")