zoukankan      html  css  js  c++  java
  • java去除字符串的html标签

    //方法一
    public String stripHtml(String content) { 
        // <p>段落替换为换行 
        content = content.replaceAll("<p .*?>", "
    "); 
        // <br><br/>替换为换行 
        content = content.replaceAll("<br\s*/?>", "
    "); 
        // 去掉其它的<>之间的东西 
        content = content.replaceAll("\<.*?>", ""); 
        // 去掉空格 
       content = content.replaceAll(" ", "");
    return content; } 方法二 public static String delHtmlTag(String str){ String newstr = ""; newstr = str.replaceAll("<[.[^>]]*>",""); newstr = newstr.replaceAll(" ", ""); return newstr; }
  • 相关阅读:
    编程心得5
    编程心得2
    心得2
    心得1
    7-11
    7-13
    7-9
    7-8
    7-12
    7-14
  • 原文地址:https://www.cnblogs.com/suruozhong/p/6692672.html
Copyright © 2011-2022 走看看