2012-05-21 32 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,,所以這可能不是你的意思。