简体   繁体   English

正则表达式 - 匹配一个字符串,但仅限于下一个单词不是'x'的情况

[英]Regex - match a string, but only where the next word is not 'x'

If I have this string: 如果我有这个字符串:

"The quick brown fox jumped over the lazy dog. What a nice brown fox that is." “快速的棕色狐狸跳过懒狗。真是个漂亮的棕色狐狸。”

What regex would I use to match the text 'brown fox' but not where the following word is 'that', ie (matches in italic): 我将使用什么正则表达式匹配文本'棕色狐狸',而不是下面的单词是'那',即(匹配斜体):

"The quick brown fox jumped over the lazy dog. What a nice brown fox that is." “快速的棕色狐狸跳过懒狗。真是个漂亮的棕色狐狸。”

你需要一个零宽度的负前瞻断言 ,即

brown fox(?! that)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM