Here you can find the source of removeTags(final String source, final String regex)
public static String removeTags(final String source, final String regex)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String removeTags(final String source, final String regex) { String modified = new String(source); Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(modified); return matcher.replaceAll(""); }//from w ww.jav a 2s. c o m public static String removeTags(final String source) { String modified = removeTags(source, "<(\"[^\"]*\"|'[^']*'|[^'\">])*>"); return replaceHTMLTags(modified); } private static String replaceHTMLTags(final String source) { String modified = new String(source); return modified.replace(" ", " ").replace("<", "<") .replace(">", ">").replace("&", "&") .replace(""", "\"").replace("\n", ""); } }