I’d like to run a preg_replace PHP function on a string but I need it to ignore anything inside anchor tags.
eg.
string = 'alpha beta delta gamma <a href="somelink.html">alpha beta delta gamma</a>'
to match = 'beta delta'
How would I get it to only pick up on the first instance of beta delta and not the second?
You can negative lookahead for a closing tag:
Also you shouldn’t use regex on html.