java去除字符串的html标签
2017-12-08 17:14
1076 查看
//方法一 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标签
- java字符串去除html标签
- java使用正则表达式去除字符串的html标签
- 一个工具类WebUtil.java(包含设置cookie,得到cookie的方法,去除字符串当中的html标签的方法等等)
- java去除字符串中的html标签的方法
- java 去html标签,去除字符串中的空格,回车,换行符,制表符
- java 去html标签,去除字符串中的空格,回车,换行符,制表符
- ASP.NET去除HTML标签并截取指定长度字符串
- java用正则去除html标签
- 去除字符串中的HTML标签
- java-正则表达式过滤字符串中的html标签
- Java去除掉HTML里面所有标签,
- java 后台去除HTML标签
- java截取带html标签的字符串并把标签补全(保证格式)
- asp.net去除字符串中html标签
- php去除字符串中的HTML标签
- java正则表达式去除html中所有的标签和特殊HTML字符(以&开头的)
- java去除html标签的正则表达
- C#去除字符串中的html标签
- C#去除指定字符串中的HTML标签相关代码函数