I used regular expression a little bit already but now I've stumbled upon a situation, where I don't really know how to do it, and all the online tutorials I read didn't cover my situation. The problem reads quite easy to solve, and it is probably easy to solve, but I didn't find a solution yet.
I need to parse a string, that is composed of short strings combined with the boolean operators AND, OR and NOT, brackets are allowed, whitespaces shouldn't matter, case insensitive.
For instance
xxxx AND (yyyy or zzzz) and not qqqq
Right now I'd like to find all the strings, that have a NOT infront of it. For that I created this regex pattern
"NOT\s+[\w]+"
(The literal NOT followed by at least one whitespace, followed by at least one letter/digit.)
This would give me "not qqqq" in the above example.
But, if the user happens to write
xxxx AND (yyyy or zzzz) and not not qqqq
which is a valid string, then my pattern would give me "not not" instead of "not qqqq".
So I need a regex pattern that would give me "literal word NOT followed by whitespace followed by any string but NOT followed by whitespace (or string end)".
I know how to negate single characters, but I didn't find any working examples that negate whole words, at least not when I test it in regexstorm.net
I use .NET.