You are doing it wrong in the first place, since you have to remove the tags. You are doing it wrong because you're using regex for HTML (sometimes it's OKish).
Variation of regex you're using should suffice: Demo
You should really consider using DOMDocument
or similar:
$html = <<<HTML
...
HTML;
$dom = new DOMDocument();
$dom->loadHTML($html);
$element = $dom->getElementsByTagName('br');
$remove = [];
foreach($element as $item){
$remove[] = $item;
}
foreach ($remove as $item) {
$item->parentNode->removeChild($item);
}
$html = $dom->saveHTML();
echo $html;
This would remove all of br
, you would need to adjust the code work for your specs, but this should be a pointer.