正则表达式匹配除包含特定模式的单词之外的所有单词

Regular expression to match all words except those containing a certain pattern

假设我有两个单词列表,我必须匹配第一个列表中的所有个单词,但是none 第二个列表 中。现在假设第二个列表中的所有单词(那些 not 被匹配的单词)包含特定的模式:character1 followed by character2 然后 character2character1 再次。例如包含"abba"、"otto"、"trillion"、"unfitting"等词

我可以使用正则表达式轻松匹配此模式 (\w)(\w)。为了匹配第二个列表中的所有单词,我可以使用 \w*(\w)(\w)\w*。但是我如何匹配除包含此模式的单词之外的所有单词?

我尝试过的其中一个方法是 (?!\w*(\w)(\w)\w*),但是,出于某种原因,它也匹配第二个列表中第一个和第二个字符之间的过渡。我知道我做错了什么,但我不知道是什么。

Zeron gets a working solution from Casimir et Hippolyte

\b(?!\w*(\w)(\w))\w+ can do the job since the word boundary ensures that you test a word from the begining. – Casimir et Hippolyte Jan 25 at 19:10