I am receiving string from server having HTML tags. I am removing these tags using regular expression like string1.replaceAll("\\<.*?>","") but the problem is that it also remove line breaks and hyperlinks. I want to keep hyperlinks and line breaks and remove everything else.
I am receiving string from server having HTML tags. I am removing these tags
Share
Don’t use regexps for parsing HTML.
To strip it completely from HTML (not what you wanted, but simple to do):
To strip it selectively, retaining only
<a>(and thehrefattribute) and<br>tags I suggest you use JSoup: