Reputation: 13
I need to find all instances of the word "confidential" in a message except when it is used in the phrase "confidential and proprietary" in which case it is ok and I dont need to pick it up through regex.
Thanks all in advance! -P
Upvotes: 0
Views: 84
Reputation: 70732
Using word boundaries \b
is also an option here.
\bconfidential\b(?! and proprietary\b)
Upvotes: 1
Reputation: 9480
You can use negative lookaround (http://www.regular-expressions.info/lookaround.html)
This regex will match: (confidential) (?!and proprietary)
if your engine support lookaround.
demo: http://regexr.com?36itq
Upvotes: 2