remove html tags

*, remove html tags

//Remove the html code in the string
	 public static String delHTMLTag(String htmlStr){
	        String regEx_script="<script[^>]*?>[\\s\\S]*?<\\/script>"; //Define the regular expression of script
	        String regEx_style="<style[^>]*?>[\\s\\S]*?<\\/style>"; //Define the regular expression of style
	        String regEx_html="<[^>]+>"; //Define the regular expression of HTML tags
	         
	        Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE);
	        Matcher m_script=p_script.matcher(htmlStr);
	        htmlStr=m_script.replaceAll(""); //Filter script tags
	         
	        Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE);
	        Matcher m_style=p_style.matcher(htmlStr);
	        htmlStr=m_style.replaceAll(""); //Filter style tags
	         
	        Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE);
	        Matches m_html = p_html.matcher (htmlStr);
	        htmlStr=m_html.replaceAll(""); //Filter html tags

	        return htmlStr.trim(); //return text string
	    }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326480551&siteId=291194637