Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String filterHtml(String html) { Pattern pattern = Pattern.compile("<style[^>]*?>[\\D\\d]*?<\\/style>"); Matcher matcher = pattern.matcher(html); String htmlStr = matcher.replaceAll(""); pattern = Pattern.compile("<[^>]+>"); String filterStr = pattern.matcher(htmlStr).replaceAll(""); filterStr = filterStr.replace(" ", ""); filterStr = filterStr.replace(" ", ""); return filterStr.trim(); } }