I am looking for the best br2nl
function. I would like to replace all instances of
and
I would generally say "don't use regex to work with HTML", but, on this one, I would probably go with a regex, considering that
tags generally look like either :
, with any number of spaces before the /
I suppose something like this would do the trick :
$html = 'this
is
some
text
!';
$nl = preg_replace('#
#i', "\n", $html);
echo $nl;
Couple of notes :
\s*
/
: /?
>
#i
), as
would be valid in HTML