how to convert string
"<br><br><br><br><br><br>" to
"<br>" using java's String.replaceAll(String, String) method?
I've tried both:
str.replaceAll("<br>+","<br>");
str.replaceAll("<br>{1,}","<br>);
but neither work.
<br>+
matches "<br>>>>>>>>"
, try this instead: (<br>)+
And if there are spaces in between the tags, do:
str = str.replaceAll("(<br>\\s*)+","<br>");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With