JAVA removes HTMl and CSS styles and javacss styles
The encapsulation method is as follows:
Public String delHTMLTag (String htmlStr) {String regEx_style = "<style [^>] *?> [\ S \ S] *? <\\/ Style> "; // define the regular expression String regEx_html =" <[^>] +> "; // define the Regular Expression Pattern p_style = Pattern for HTML tags. compile (regEx_style, Pattern. CASE_INSENSITIVE); Matcher m_style = p_style.matcher (htmlStr); htmlStr = m_style.replaceAll (""); // filter the style label Pattern p_html = Pattern. compile (regEx_html, Pattern. CASE_INSENSITIVE); Matcher m_html = p_html.matcher (htmlStr); htmlStr = m_html.replaceAll (""); // filter html tags htmlStr = htmlStr. replace ("", ""); htmlStr = htmlStr. replaceAll ("\ s * | \ t | \ r | \ n", ""); htmlStr = htmlStr. replace ("", ""); htmlStr = htmlStr. replace ("", ""); htmlStr = htmlStr. replaceAll ("", ""); return htmlStr. trim (); // returns a text string}
This article references: http://blog.csdn.net/shiyuezhong/article/details/8122861