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

<p class="p1">
<span>A. She has been to the market.</span>
</p>
保留
A. She has been to the market.
最新回答
泪海

2021-01-12 21:16:56

用JavaScript方法如下,JAVA语言类似:
'你的HTML文本'.replace(/.+>(.+)<.+/,'$1')
賲呗^ō^钸哭

2020-08-10 07:02:12

1
2
3

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

收起 1条折叠回答
var str ='<p class="p1"><span>A. She has been to the market.</span></p>';
var reg = /.*>([^<>]+)<.*/;
str.replace(reg,'$1');