[英]Make a regex not match if a certain string is found in the match?
Lets say i have some random easy match like 可以说我有一些随机的简单比赛,例如
\bword\b
Now i want to add to this that if before this match there is lets say this 现在我想补充一点,如果在这场比赛之前有一个可以说的话
(HOUSE[ ]*?)\bword\b
So if the word HOUSE and whatever ammount of spaces is infront of word then the match should be false. 因此,如果单词HOUSE和任何数量的空格位于单词的前面,则匹配项应为false。 So my question more or less is how do i negate the (HOUSE[ ]*?) query?
所以我的问题或多或少是我如何否定(HOUSE [] *?)查询?
You use a negative lookbehind. 您在后面使用了负数。 In .NET lookbehinds can be variable length:
在.NET中,lookbehinds可以是可变长度的:
(?<!HOUSE[ ]*?)\bword\b
Reference : 参考 :
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.