2014-11-03 151 views
-1

我在寻找一个正则表达式模式,它匹配除一个确切单词外的所有内容。正则表达式:匹配除一个单词外的所有内容

例如,分辨率:

monitors/resolutions // Should not match 
monitors/34   // Should match 
monitors/foobar  // Should match 

我知道,你可以排除单个字符的列表,但你如何排除一个完整的字?

+1

的可能重复的[A正则表达式来排除字/串(http://stackoverflow.com/questions/2078915/a-regular-expression-to-exclude-a-word-string) – 2014-11-03 11:34:10

+1

这是这里最常问到的问题之一,请在询问之前进行搜索。 – 2014-11-03 11:34:28

回答

1

使用负前向断言,

^(?!.*resolutions).*$ 

OR

^(?!.*\bresolutions\b).*$ 

DEMO

相关问题