实例如下:
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(" ", ""); // 还原html // content = htmldecoder.decode(content); return content; } public static string delhtmltag(string str){ string newstr = ""; newstr = str.replaceall("<[.[^>]]*>",""); newstr = newstr.replaceall(" ", ""); return newstr; }
以上这篇java 语言实现清除带 html 标签的内容方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
case when + forEach 实现多条件多值批量更新
这些令人喷饭的代码注释,最后一个让我笑出了声(今日份的快乐源泉)
网友评论