简体   繁体   中英

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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