<?php
$tests = array(
'First line<br>second line<br>third line',
'First line <br>second line <br>third line',
'First line<br> second line<br> third line',
'First line <br> second line <br> third line',
'First line <br> second line<br>third line',
'First line <br> second line <br>third line',
'First line<br>second line <br> third line',
'First line <br> second line<br> third line',
'First line<br> second line <br> third line',
'First line<br/>second line<br/>third line',
'First line <br/>second line <br/>third line',
'First line<br/> second line<br/> third line',
'First line <br/> second line <br/> third line',
'First line <br/> second line<br/>third line',
'First line <br/> second line <br/>third line',
'First line<br/>second line <br/> third line',
'First line <br/> second line<br/> third line',
'First line<br/> second line <br/> third line',
'First line<br />second line<br />third line',
'First line <br />second line <br />third line',
'First line<br /> second line<br /> third line',
'First line <br /> second line <br /> third line',
'First line <br /> second line<br />third line',
'First line <br /> second line <br />third line',
'First line<br />second line <br /> third line',
'First line <br /> second line<br /> third line',
'First line<br /> second line <br /> third line',
'First line<br class="hide-on-mobile" /> second line <br class="hide-on-mobile" /> third line',
);
foreach ( $tests as $test ) {
echo preg_replace( '/(\s)?<br(.*?)>(\s)?/', ' ', $test ), PHP_EOL;
}
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line
First line second line third line