【发布时间】:2020-07-29 15:51:43
【问题描述】:
请帮忙,如果字符串中存在某个单词,如何排除字符串的存在。
例子:
any text here my text any text word wrong any text
any text here my text any text true any text
any text here my text any text wrong any text
此正则表达式标记所有行 (https://regex101.com/r/rrgEp6/1):
here([a-z, ]{0,70})((?:(?! word))) (wrong|true)
在这种情况下需要排除单词-“单词”:
any text here my text any text true any text
any text here my text any text wrong any text
【问题讨论】:
-
你想要
here((?:(?!\bword\b)[a-z ,]){0,70}) (wrong|true),见demo。