<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')
'你的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');
var reg = /.*>([^<>]+)<.*/;
str.replace(reg,'$1');
[^<>]不包含尖括号以确保不会匹配到标签,实际情况可能要加全局g或多行m匹配