正则表达式: 找出不含(排除)某个字符串的所有

Match string not containing string

Given a list of strings (words or other characters), only return the strings that do not match.


以正则表达式 ^((?!badword).)*$ 搜索以下内容将会得到除1、4行以外的所有内容。此表达式对于log搜索比较有用。

badword可以替换为一组字符串,如(ECSdk|MOS),表达式^((?!(ECSdk|MOS)).)*$意为排除ECSdk和MOS 所在的行。

badword
test
one two
abadwords

three


参考:

https://www.regextester.com/15


猜你喜欢

转载自blog.csdn.net/lancewoo/article/details/80691843