码迷,mamicode.com
首页 > 编程语言 > 详细

java 去掉html标签

时间:2018-04-25 17:01:02      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:eal   AC   它的   string   html   标签   java   nbsp   pre   

public static String stripHtml(String content) { 
// <p>段落替换为换行 
content = content.replaceAll("<p .*?>", "\r\n"); 
// <br><br/>替换为换行 
content = content.replaceAll("<br\\s*/?>", "\r\n"); 
// 去掉其它的<>之间的东西 
content = content.replaceAll("\\<.*?>", ""); 
// 还原HTML 
// content = HTMLDecoder.decode(content); 
return content; 
}

 

java 去掉html标签

标签:eal   AC   它的   string   html   标签   java   nbsp   pre   

原文地址:https://www.cnblogs.com/firstdream/p/8945357.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!