I have a string like below.
<br><br><br><br><br> SomeHtmlString <br><br><br><br><br>
I want to remove br tags like trim function preserving middle br tags in SomeHtmlString.
Is there any function to do this shortly?
e.g.
<br><br><br>test1<br><br>test2<br><br><br><br>
to
test1<br><br>test2
Here is a method using regular expressions. It matches only one
at a time and replaces that either at the beginning of end of the string.
and that does strip
"<br><br > <br > test<br>test2<br><br>"down totest<br>test2.It’s probably not the neatest solution but it is very easy to modify to match different expressions, with different whitespace, for example.
It’s also possible to use the regular expressions to match several
<br>s in one go:which avoids the looping but is a little harder to modify.