Multiple filter replacement
*/ const reg = /(? < = >) [^ >] + (? = < / [\]? \w+.*>)/g; this.content = this.savaObj.personDetail.replace(reg, (s) => { // console.log(s); / / return s.place (/* linght = new RegExp(linght, "gm"), '<span style="color: #218BF7; font-weight: bold;" >${linght}</span>` ); });Copy the code
There is a bug in replacing rich text content
Is a small program ios will appear white during which js (use the whole page will hang the subcontract) if you use the < = error will open the white, only the ios side, but use real machine debugging sure developers.weixin.qq.com/community/d again…
Js regular expression modifier /ig
let strs = `<p style="width: 9rpx">123</p> <h1 style='width: 9rpx'>123</h1>`; var patt1 = /[^>]+(? = < / [\]? \w+.*>)/g; console.log(strs.match(patt1)) // ["123", " ", "123"]Copy the code