Use a trick: concatenate the string from two pieces. This way, the closing tag is cut in two, and is not a valid closing tag anymore. '?>' --> '?'.'>'
In your code:
$string = preg_replace('#<br\s*/?'.'>(?:\s*<br\s*/?'.'>)+#i', '<br />', $string);
This will make // comments work.
For /* */ comments to work, you’d have to split the */ sequence too:
$string = preg_replace('#<br\s*'.'/?'.'>(?:\s*<br\s*'.'/?'.'>)+#i', '<br />', $string);
Remember, sometimes, even though the whole is more than the sum of its parts – but being greedy is bad, there are times you are better left with less. 🙂