I have a large data set of html text, and I frequently find unnecessary, and sometimes multiple, <br>
line breaks within <li>
tags.
For example:
<li>Some string here<br></li><br><li>Another string here<br><br></li><br>
I would like to remove these <br>
that appear between <li>
and </li>
but preserve everything else, including <br>
outside of <li>
tags. The text above would become:
<li>Some string here</li><br><li>Another string here</li><br>
What is the regular expression for doing this with preg_replace() in php (or re.sub() in python)?