[英]Regex to find a word then exclude specific words from consideration
I have the following regex which I use to find a word: 我有以下用于查找单词的正则表达式:
(?<=\\s)([\\w\\@\\-]+)(?=\\s)
I want to further modify this regex to exclude a list of words eg do not match if the word is 'cat' or 'dog'. 我想进一步修改此正则表达式以排除单词列表,例如,如果单词是“ cat”或“ dog”则不匹配。
How do I accomodate the regex to achieve this? 我如何适应正则表达式来实现这一目标?
\b(?!(?:dog|cat)\b)([\w@-]+)\b
在这里,如果您想将单词开头/结尾与@
匹配
(?<=\s)(?!(?:dog|cat)(?=\s))([\w\@\-]+)(?=\s)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.