vishal23
asked on
Regular Expression that matches a phrase that doesn't contain this word
I need help writing a regular expression in c# that will match a pattern that does not contain a certain subpattern.
My source string: "this is notgood this is good"
What I want it to return/match: this is good
My regex MUST be something like: this.*good
But right now it will return the whole source string:
So my questions is how do I modify "this.*good" to ignore the part that has NOTGOOD and only return "this is good" ?
I tried this.*[^(notgood)]*good but that doesn't do it. The [^notgood] excludes only single characters not words.
I am testing the regex here: http://regexlib.com/RETester.aspx
Thanks.
My source string: "this is notgood this is good"
What I want it to return/match: this is good
My regex MUST be something like: this.*good
But right now it will return the whole source string:
So my questions is how do I modify "this.*good" to ignore the part that has NOTGOOD and only return "this is good" ?
I tried this.*[^(notgood)]*good but that doesn't do it. The [^notgood] excludes only single characters not words.
I am testing the regex here: http://regexlib.com/RETester.aspx
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.