首页 > 编程语言 > 详细

java去除字符串的html标签

时间:2017-04-11 14:02:52      阅读:193      评论:0      收藏:0      [点我收藏+]
//方法一
public String stripHtml(String content) { 
    // <p>段落替换为换行 
    content = content.replaceAll("<p .*?>", "\r\n"); 
    // <br><br/>替换为换行 
    content = content.replaceAll("<br\\s*/?>", "\r\n"); 
    // 去掉其它的<>之间的东西 
    content = content.replaceAll("\\<.*?>", ""); 
    // 去掉空格 
   content = content.replaceAll(" ", "");
return content; } 方法二 public static String delHtmlTag(String str){ String newstr = ""; newstr = str.replaceAll("<[.[^>]]*>",""); newstr = newstr.replaceAll(" ", ""); return newstr; }

 

java去除字符串的html标签

原文:http://www.cnblogs.com/suruozhong/p/6692672.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!