I'm trying to write a regex that will match a given pattern between 2 and unlimited times. Effectively I'm just trying to combine multiple line breaks in to one, if any exist at all.
Sample input:
<br><br>
<br>
ABC
<br>
<br>
Expected output:
<br>
ABC
<br>
If the regex was run on the above output then I would expect to see the exact same output.
There could be any amount of whitespace between the <br> tags.
What I've tried:
$html = preg_replace('/(?:<br>\s?){2,}/s', null, $html);
\r\n), consider replacing matches of/\n{2,}/with\nor/\n(?=\n)/with an empty string (both with the multiline flag set) .