I'm trying to find a regex that finds all words that are not within anchor tags. I already have a variant that works quite well, but unfortunately it doesn't work if the tags are nested.
Here is my expression:
(.*?)(\bFoobar\b(?!([^<>]*[^<>]*|[^<>]*)(<\/a|>)))(.*$)
This works, it finds Foobar:
<strong>Foobar</strong> bar baz
This works as well, it does not find Foobar, cause its inside anchor tag:
<a href="foobar.com">Foobar</a> bar baz
But this does not work, it finds Foobar:
<a href="foobar.com"><strong>Foobar</strong></a> bar baz
Thanks for your help.