I am trying to replace some html in php with preg_replace and I don't seem to get the regex fine, because I always screw it up.
Could you please help me with it ?
I have the following:
<ol><li>text</li><li>text</li></ol>
<ol><li><ul><li>text</li></ul></li></ol>
And I want to insert a <span></span>
right after <li>
and place the text in <p>
. I must note that I don't want the <li>
inside the <ul>
to be affected.
Rather than trying to write a single regexp to handle this (I think it might be possible to do it with a look-behind type match) it'd be easiest to:
<ol>
with preg_match_all()
<li>
in the results ensuring that it's not wrapped in a <ul>