当前位置:网站首页>js 正则删除span标签以及标签里面的内容
js 正则删除span标签以及标签里面的内容
2022-07-22 22:09:00 【京城落灬雨烟】
如题:拿到后台返回的数据是一个带p标签和span标签的的字符串,本来v-html引用就完了,但是有个奇葩需求需要删掉span标签及里面的内容,费了半天劲终于实现了。
var temp="<p dw='6e290ab04f4e4e32bf5f2ed8dc5a1b04'>从发达国家建设工程的发展规律来看,<span
class ='hd'>Caf律基n;y设a础建设c能看tou家o的t工规从(i 施展程的来n达“i发国续p 持发cCna力
</span>基础设施的“持续能力(Capacity of Continuance)”建设和“可持续的运营、维护基础设施(Sustainable operation&maintenance)”是城市化后期的国家所面临的共同问题。<span class
='hd'>从n家np发国持 力y设 看C“(no础施fa工达规的at展t来续;caucC设基律i的发建程能oi</span>从
国内情况来看,<span class ='hd'>tp设u律o发展的施naa(t看持“ao从达;i家ync发i力工fc 建程基规续
C的nC 国能设础来</span>一方面,<span class ='hd'>c基础的Cf力C达c 工展i能no程的t从aoan;n建(a家规u“来 i看t律国设y发发设持p续施</span>目前大型建设项目实施过程中出现“伪可持续发展”的倾向和
后果;另一方面,<span class ='hd'>国础tio发n工C展的“规 a设i发设程(从施持cC续 o基nnyfaua能c
的来建达tp力看律家;</span>随着城市化进程的逐步深入,<span class ='hd'>从na工 发家能Ccinp 看
施国的续oCa设(ut展“设律建达基发ciy程来o力规;t持的fa础n</span>我国的基础设施(包括投入使用和未
投入使用的)必然也面临发达国家目前的问题。<span class ='hd'>续的C发c 设建从u基y力i达“律家onn
工iac国能础f来程(;Ct看 n持ao施发t规p展设的a</span></p >"
//去掉span标签里面的所有内容
var result=temp.replace(/<span\b[^<]*(?:(?!<\/span>)<[^<]*)*<\/span>/gi,"")
console.log(result)
//得到的结果
<p dw="6e290ab04f4e4e32bf5f2ed8dc5a1b04">从发达国家建设工程的发展规律来看,基础设施的“持续能力(Capacity of Continuance)”建设和“可持续的运营、维护基础设施(Sustainable operation&maintenance)”是城市化后期的国家所面临的共同问题。从国内情况来看,一方面,目前大型建设项目实施过程中出现“伪可持续发展”的倾向和后果;另一方面,随着城市化进程的逐步深入,我国的基础设施(包括投入使用和未投入使用的)必然也面临发达国家目前的问题</p >如果要修改其它标签的话,同理直接把正则表达式里面的span换成其它的标签就行了。
边栏推荐
- 互联网流量编排方案
- Expérience II Yuv
- Mysql A left(right) join B on A.id=B. ID and a.age=1 and a left (right) join b on a.id=b id where A.age=1
- 实验七 H.264文件分析
- There are 13 detailed methods for JMeter to view the response of the result tree!
- matlab 分数阶pid控制
- wps数据拆分
- 使用路由协议配置 IPv6 over IP手动隧道
- Arduino中断实现上升沿检测,并执行其他函数
- 高精度移相(MCP41xx)程序stm32F103,F407通用,更改引脚即可(SPI软件模拟通信)
猜你喜欢

初出茅庐的小李第109篇博客之如何打开Keil中文件的真是路径

QT document reading notes - qaudioinput & qaudioformat parsing and examples

【干货原创】发现了一个好用到爆的数据分析利器

Customize flick es source
![Reading notes - > statistics] construction of 12-02 confidence interval -t distribution concept introduction](/img/4d/25b4d3d6af0fb30c222613d3c428b7.png)
Reading notes - > statistics] construction of 12-02 confidence interval -t distribution concept introduction

21 -- product of arrays other than itself

Experiment 2 YUV

开发者分享|『啃书吧:深度学习与MindSpore实践』第一章

技术干货 | 数据处理好难?来看MindSpore提供的解决思路!

项目升级遇到的坑
随机推荐
H7-TOOL串口脱机烧录操作说明,支持TTL串口,RS232和RS485(2022-06-30)
Spark troubleshooting -precondition eof: no length prefix available
Reading notes - > statistics] construction of 12-02 confidence interval -t distribution concept introduction
Yolov5 post-processing code of cpu/gpu (CUDA) version
VMware virtual machine changes static IP and hostname, and uses xshell to connect
SQL报错盲注实例分析
JVM监控工具介绍jstack, jconsole, jinfo, jmap, jdb, jstat
Expérience II Yuv
学会这些Sketchup技巧,工作效率提高一半
[day 31] given an integer n, find the base and exponent of each prime factor | basic theorem of arithmetic
互联网流量编排方案
实验三 LZW
matlab simulink 水能和同步电机发电
目标检测之锚点与锚框
[reading notes > statistics] 12-01 construction of confidence interval - Introduction to the concept of confidence interval
初出茅庐的小李第109篇博客之如何打开Keil中文件的真是路径
VMware虚拟机更改静态IP和主机名,使用Xshell进行连接
Leetcode day 26
Rust——关于Option详解
wps数据拆分