I have a regular expression that is used to replace a phrase if the phrase is not contained by HTML anchor tags or an IMG tag. For this example the phrase being searched for is "hello world"
The .net regular expression is
(?<!<a [^<]+)(?<!<img [^<]+)(?<=[ ,.;!]+)hello world(?=[ ,.;&!]+)(?!!.*</a>)
E.G. The regular expression should match "hello world" in a phrase like
"one two three hello world four five"
But shouldn't match hello world in a phrase like
"one two three <a href='index.html'> hello world </a> four five"
or
"one two three <img alt='hello world' \>four five"
It is associated with the following question from when I was originally developing the .Net version. regular expression that doesn't match a string if it's the text within an html anchor tag
Any guidance on how to go about converting this to a php regex would be very much appreciated.