All QA about matching something except word with negative look-ahead that I found imply lines start/end(^
$
). But I can't figure out how can I match everything (any character like .*
) except word before some other word in the middle of the processed text.
I should match ABC
inside <tag></tag>
:
...<tag>a a.__aABC&*</tag>aaa<tag>ffff</tag>...
but not outside (false-positive):
...<tag>a a.__a&*</tag>ABC<tag>ffff</tag>...
So I think I should exclude tag closing (</tag>
) before ABC
.
I tried:
<tag>(?!<\/tag>)ABC.*?<\/tag>
but such way it doesn't allow to match .*
except </tag>
before ABC
. How can I implement this?
Useful links: