过滤html

来源:互联网 发布:c语言定义变量 编辑:程序博客网 时间:2024/05/22 00:51
public static String removeTagFromText(String content) {
  Pattern p = null;
  Matcher m = null;
  String value = null;
  // 去掉<>标签
  p = Pattern.compile("(<[^>]*>)");
  m = p.matcher(content);
  String temp = content;
  while (m.find()) {
   value = m.group(0);
   temp = temp.replace(value, "");
   }
    return temp;
 }
原创粉丝点击