Regex - matches the string, but only where the next word is not "x",

If I have this line:

"The quick brown fox jumped over the lazy dog. What a beautiful brown fox."

In what regular expression will I use the text “brown fox”, but not where the next word “is”, i.e. (matches italics):

"The quick brown fox jumped over the lazy dog. What a beautiful brown fox."

+3
source share
1 answer

You need a negative statement with zero width , i.e.

brown fox(?! that)
+8
source

Source: https://habr.com/ru/post/1765966/


All Articles