過濾文章中的html標籤,實現的方式都是將html標籤替換掉,都是使用正則表達式 下面列出幾種 經常過濾的字符
String content = "文章內容";
// 過濾文章內容中的html
content =content.replaceAll("</?[^<]+>","");
// 去除字符串中的空格 回車 換行符 製表符 等
content = content.replaceAll("\\s*|\t|\r|\n", "");
// 去除空格
content = content.replaceAll(" ", "");
// 去掉其他一些字符
content = content.replaceAll("\", "");
後面的如果有特殊字符,根據自己需要進行過濾。