正则表达式 替换或去掉字符串中的 <p></p>标签 如 : 张三<p>aaaa</p>历史<p>bbbb</p>

如题所述

如果要替换掉<p>aaaa</p>,包括内容,就把<p>[^<]*?</p>替换为空

如果要替换掉<p></p>,不包括中间的内容,就把<p>([^<]*?)</p>替换为$1
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-01-30
查找的表达式
<p>[^<]*?</p>

替换的表达式
[什么都不要填]
第2个回答  2018-04-14
String str ="<p>陆羽《茶经》有言:山水上,江水下,井水次。</p><p>【茶圣陆羽排出的宜茶之水】:</p><p> 第一、庐山康王谷水帘水;</p><p> 第二、无锡惠山寺石泉水;</p>"
String contentStr ;
if (str .contains("<p>")) {
contentStr = answer.getContent().replace("<p>", " ");
contentStr = contentStr.replace("</p>", " ");
Log.e("123"," "+contentStr );
}
相似回答