The Java language implements methods to clear content with html tags
- 2020-06-07 04:26:31
- OfStack
Examples are as follows:
public String stripHtml(String content) {
// <p> Replace paragraphs with newlines
content = content.replaceAll("<p .*?>", "\r\n");
// <br><br/> Replace it with a newline
content = content.replaceAll("<br\\s*/?>", "\r\n");
// Get rid of the others <> Between things
content = content.replaceAll("\\<.*?>", "");
// Remove the blank space
content = content.replaceAll(" ", "");
// reduction HTML
// content = HTMLDecoder.decode(content);
return content;
}
public static String delHtmlTag(String str){
String newstr = "";
newstr = str.replaceAll("<[.[^>]]*>","");
newstr = newstr.replaceAll(" ", "");
return newstr;
}