2012-05-21 62 views
0

我想从消息如何排除字符串

的VSS作家耗尽了内存

正则表达式我使用模式匹配排除字符串“VSS”是

[O,o]ut of [M,m]emory 

但是如果VSS出现在消息中,我想排除整个消息。这可能吗?

+2

什么编程语言? –

回答

3

您可以在此使用负lookahead assertion解决:

(?i)^(?!.*VSS).*out of memory 

说明:

(?i)   # Make the regex case-insensitive 
^    # Match the start of the string 
(?!.*VSS)  # Assert that there is no "VSS" in the string 
.*    # Match any number of characters 
out of memory # Match "out of memory" 

顺便说一句,[O,o]匹配的O,一个o,,所以这可能不是你的意思。