日期:2014-05-17 浏览次数:20649 次
/** * 去除str中的HTML标签 * * @param str * @return */ public static String formatHtml(String str) { if (str == null) { return ""; } str = str.toLowerCase(); str = str.replaceAll("</?span[^>]*>", ""); str = str.replaceAll("&#[^>]*;", ""); str = str.replaceAll("</?marquee[^>]*>", ""); str = str.replaceAll("</?object[^>]*>", ""); str = str.replaceAll("</?param[^>]*>", ""); str = str.replaceAll("</?embed[^>]*>", ""); str = str.replaceAll("</?table[^>]*>", ""); str = str.replaceAll(" ", ""); str = str.replaceAll("</?tr[^>]*>", ""); str = str.replaceAll("</?th[^>]*>", ""); str = str.replaceAll("</?p[^>]*>", ""); str = str.replaceAll("</?a[^>]*>", ""); str = str.replaceAll("</?img[^>]*>", ""); str = str.replaceAll("</?tbody[^>]*>", ""); str = str.replaceAll("</?li[^>]*>", ""); str = str.replaceAll("</?div[^>]*>", ""); str = str.replaceAll("</?td[^>]*>", ""); str = str.replaceAll("</?script[^>]*>", ""); str = str.replaceAll("(javascript|jscript|vbscript|vbs):", ""); str = str.replaceAll("on(mouse|exit|error|click|key)", ""); str = str.replaceAll("<\\?xml[^>]*>", ""); str = str.replaceAll("<\\?[a-z]+:[^>]*>", ""); str = str.replaceAll("</?font[^>]*>", ""); str = str.replaceAll("</?b[^>]*>", ""); str = str.replaceAll("</?u[^>]*>", ""); str = str.replaceAll("</?i[^>]*>", ""); str = str.replaceAll("</?strong[^>]*>", ""); str = str.replaceAll("</?(a|A)( .*?>|>)", ""); return str; }
?