Consider the following HTML string:
<p>This is line 1 <br /> and this is line 2</p>
How can i replace the above with the following string using PHP / Regex
<p><span class="single-line">This is line 1</span><span class="single-line">and this is line 2</span></p>
This works but I would advise you not to rely on regular expressions for HTML parsing / transformation: