用过的正则做一下记录
- 指定开头中间和结尾匹配出结果
const string = "<p><img data-local="aaa" class="small-img" src="data:image/png;base64" >
<img data-local="bbb" class="small-img" src="data:image/png;base64" ></p>"
const k = 'aaa'
const regex = new RegExp(`<img.*?${k}.*?>`,'g') // regex = /<img.*?aaa.8?>/g
const result = string.match(regex)[0] // <img data-local="aaa" class="small-img" src="data:image/png;base64" >
标签:regex,aaa,string,记录,正则,const
From: https://www.cnblogs.com/hjlong2/p/17732369.html