Sometimes you want to match "unknown" text, but theres One Word, that SHOULDN'T be in the text.
Heres a little Example, how to exclude a word from being matched.
You want to Match "EVERYTHING" inside a div-area but not, if
theres the word "Flower" in it (You dont like Flowers, so you dont want to match that.)
৺Regex doesnt serve any possibilty to exclude "Words" - so you need to use a workarround like this one:
Match everything between the div-tags
/<div>([^<]+?)<\/div>/
Not a Masterpiece ;-)
Thought
We "can't" exclude words - but we can exclude a char followed by a phrase.
So we exclude any char followed by "lower":
/<div>([^<](?!lower))+?+?)<\/div>/
This doesnt match a text with other words ("Glower" "Alower") too...
So we need to "modify" our "lookahead" with another "lookbehind":
/<div>((?:[^<](?!(?<=F)lower))+?)<\/div>/
Thats's the Magic :-)
This Matches All text between the divs but not, if theres the word "Flower" in it.