I need to find and replace text in a case insensitive way, unless it is within an anchor tag - for example:
<p>Match this text and replace it</p>
<p>Don't <a href="/">match this text</a></p>
Searching for 'match this text' would only replace the first instance.
[Edit] As per Gordon's comment, it may be preferred to use DOMDocument in this instance. I'm not at all familiar with the DOMDocument extension, and would really appreciate some basic examples for this functionality.