[eluser]sophistry[/eluser]
three things which won't solve your issue, but may help you move forward more swiftly:
- if you want to only replace tags OUTSIDE of html tags, then why does the replacements var show $tag IN an anchor tag?
- which HTML tags? is it only text in anchor tags you need to protect? or is there some other tag?
- why do you use a negative assertion ?! and then a negated character class [^<] in the patterns var? that's confusing to have a double-negative in a pattern. you could probably simplify that. EDIT: also, incidentally, i see the star has no repeat on it which means zero or one character.
cheers.