I'm trying to make a string replace on text in order to highlight substrings.
Those paragraphs however may include nested inline forms which also potentially contain the text string to replace. Replacing the string there obviously busts the form.
This is why I'm looking for a way in PHP to limit string replacement to all occurrences in a tag (p) which are NOT inside a nested tag (form).
Example code would for illustration would be something like this:
<p>A hedgehog is any of the spiny mammals of the subfamily Erinaceinae and the order Erinaceomorpha. There are 17 <form style="display: inline" id="lnk_123" action="hedgehog_species.html">
<input type="hidden" name="id" value="1" />
<input type="hidden" name="gps_src_lbl" value="hedgehog" />
<button type="submit" name="submit">species</button></form> of hedgehog in five genera, found through parts of Europe, Asia, Africa, and New Zealand).</p>
If I made a string replace on "hedgehog", it'd make the form useless as it would replace part of the action attribute, and the hidden input field.
Thanks in advance for your help