Javascript RegExp忽略HTML标记
我有一串文字Javascript RegExp忽略HTML标记,javascript,regex,vue.js,Javascript,Regex,Vue.js,我有一串文字 <p>This is some text <span style="color: rgb(54, 54, 54);"> and here is a bit more</span> and even more. </p> 这是一些文本 还有一点 甚至更多。 这个regexp]*>将从中获取以下内容 <p> <span style="color: rgb(54, 54, 54);"><
<p>This is some text
<span style="color: rgb(54, 54, 54);"> and here is a bit more</span>
and even more.
</p>
这是一些文本
还有一点
甚至更多。
这个regexp]*>
将从中获取以下内容
<p>
<span style="color: rgb(54, 54, 54);"></span>
</p>
我怎么才能得到相反的结果呢?我希望得到的文本,而不是。一直在到处搜索,只找到使用上述regexp进行内容替换以去除标签的人
我希望在我的VueJS应用程序中搜索文本。首先,如果您可以访问dom,请使用nodeElement.innerText 如果不能,那么html很可能是一个字符串,所以只需使用正则表达式并替换为空字符串即可得到相反的结果
console.log('1'),target.innerText);
console.log('2')、target.innerHTML.replace(/]*>/g')代码>
这是一些文本,这里有更多的内容。