I\'m trying to write a regular expression to match anything that isn\'t \"foo\" and \"bar\". I found how to match anything but one word at Regular expression to match a lin
Answer to the question: "How to add a second word to this critera?"
The answer of the question you link to is:
^((?!word).)*$
Where (?!word)
is a negative look-ahead. The answer for this question is:
^((?!wordone|wordtwo).)*$
Works for both words. Note: you should enable the global and multiline options, if you have multiple lines and want to match for each line, as the other question.
The difference is the negative look-ahead clause: (?!wordone|wordtwo)
. It can be extended to any (reasonable) amount of words or clauses.
See this answer for a detailed explanation.