java正则表达式过滤html p标签

<p class="p1">
<span>A. She has been to the market.</span>
</p>
保留
A. She has been to the market.

用JavaScript方法如下,JAVA语言类似:
'你的HTML文本'.replace(/.+>(.+)<.+/,'$1')
温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-04-13
var str ='<p class="p1"><span>A. She has been to the market.</span></p>';
var reg = /.*>([^<>]+)<.*/;
str.replace(reg,'$1');

[^<>]不包含尖括号以确保不会匹配到标签,实际情况可能要加全局g或多行m匹配

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网