I need a regular expression to match words that are not in a specific list I have.
This is for a system I haven't made, but I need to use for filtering. Apparently it filters the fields according to the regular expression given, the fields contain only one word. So I want whole word matches.
For example I want any word other than tomato or potato, my regex so far:
^(?!(Potato|Tomato))
I am testing my regular expression here. When I input Potato I get:
Your pattern does not match the subject string.
That is the result I expect, but whenever I input anything else other than Tomato and Potato, like "chocolate" I get:
No match groups were extracted.
This means that your pattern matches but there were no (capturing (groups)) in it that matched anything in the subject string.
I tried changing my expression to:
([[:alnum:]])*^(?!(Potato|Tomato))
Meaning, I want any combination of alphanumeric characters except the words "Tomato" and "Potato", but I get the same results.
I don't know how to change my regex so it has a capturing group that matches what I need.