正则踩坑一

$1,$2.....:显示括号里的第一个;显示括号里的第二个....

let content='<img  src="http://qiniu.ve-link.com/files/3/3/45/b20e446593872e59a99aff02edca5c9a450e4533.jpg" style="height:200rpx"/>'

content=content.replace(/<img([sw"-=/.:;]+)(?:(style="[^"]+"))/g, '<img$2')
console.log(content) //<imgstyle="height:200rpx"/>
 
 
content=content.replace(/<img([sw"-=/.:;]+)(?:(style="[^"]+"))/g, '<img$1')
console.log(content) //<img  src="http://qiniu.ve-link.com/files/3/3/45/b20e446593872e59a99aff02edca5c9a450e4533.jpg" />
原文地址:https://www.cnblogs.com/mcll/p/11772441.html