匹配不包含所有指定元素的字符串的正则表达式
Regular expression to match strings that do NOT contain all specified elements
我想找到一个正则表达式来匹配不包含所有指定元素的字符串,无论它们的顺序如何。例如,给定以下数据:
one two three four
one three two
one two
one three
four
将单词 two three
传递给正则表达式应该匹配行 one two
、one three
和 four
.
我知道如何实现一个表达式来匹配不包含任何单词的行,只匹配行 four
:
^((?!two|three).)*$
但对于我描述的情况,我迷路了。
我想找到一个正则表达式来匹配不包含所有指定元素的字符串,无论它们的顺序如何。例如,给定以下数据:
one two three four
one three two
one two
one three
four
将单词 two three
传递给正则表达式应该匹配行 one two
、one three
和 four
.
我知道如何实现一个表达式来匹配不包含任何单词的行,只匹配行 four
:
^((?!two|three).)*$
但对于我描述的情况,我迷路了。