匹配字符串不包含某个短语 [英] Match string not containg a certain phrase
本文介绍了匹配字符串不包含某个短语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在消息中找到机密"一词的所有实例,除非在短语机密和专有"中使用它,在这种情况下可以,我不需要通过正则表达式获取它.
I need to find all instances of the word "confidential" in a message except when it is used in the phrase "confidential and proprietary" in which case it is ok and I dont need to pick it up through regex.
先谢谢大家!-P
推荐答案
使用单词边界 \b
也是这里的一个选项.
Using word boundaries \b
is also an option here.
\bconfidential\b(?! and proprietary\b)
这篇关于匹配字符串不包含某个短语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文