public static final String Upset = " "; public static String killTags(String news) { String s = news.replaceAll("amp;", "").replaceAll("<","<").replaceAll(">", ">"); Pattern pattern = Pattern.compile("<(span)?\\sstyle.*?style>|(span)?\\sstyle=.*?>", Pattern.DOTALL); Matcher matcher = pattern.matcher(s); String str = matcher.replaceAll(""); Pattern pattern2 = Pattern.compile("(<[^>] >)",Pattern.DOTALL); Matcher matcher2 = pattern2.matcher(str); String strhttp = matcher2.replaceAll(" "); String regEx = "(((http|https|ftp)(\\s)*((\\:)|:))(\\s)*(//|//)(\\s)*)?" "([\\sa-zA-Z0-9(\\.|.)(\\s)*\\-] ((\\:)|(:)[\\sa-zA-Z0-9(\\.|.)&%\\$\\-] )*@(\\s)*)?" "(" "(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])" "(\\.|.)(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)" "(\\.|.)(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)" "(\\.|.)(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])" "|([\\sa-zA-Z0-9\\-] (\\.|.)(\\s)*)*[\\sa-zA-Z0-9\\-] (\\.|.)(\\s)*[\\sa-zA-Z]*" ")" "((\\s)*(\\:)|(:)(\\s)*[0-9] )?" "(/(\\s)*[^/][\\sa-zA-Z0-9\\.\\,\\?\\'\\\\/\\ &%\\$\\=~_\\-@]*)*"; Pattern p1 = Pattern.compile(regEx,Pattern.DOTALL); Matcher matchhttp = p1.matcher(strhttp); String strnew = matchhttp.replaceAll("").replaceAll("(if[\\s]*\\(|else|elseif[\\s]*\\().*?;", " "); Pattern patterncomma = Pattern.compile("(&[^;] ;)",Pattern.DOTALL); Matcher matchercomma = patterncomma.matcher(strnew); String strout = matchercomma.replaceAll(" "); String answer = strout.replaceAll("[\\pP‘’“”]", " ") .replaceAll("\r", " ").replaceAll("\n", " ") .replaceAll("\\s", " ").replaceAll(Upset, ""); return answer; } |