A rule found on the Internet is not very clear. I would like to ask the bosses
function me(str){
return str.replace(/<img [^>]*src=[""]([^""]+)[^>]*>/gi, function (match, capture) {
console.log(match)
console.log(capture)
return match.replace(new RegExp("(" + capture + ")", "g"),"https://aishou.yuxwl.top"+capture)
})
the above method is to match the img tag in the string to replace the src address in the img tag, and then return to the original string. The idea has been implemented, but it is not clear.
I don"t understand why the a.png
printed out by the second parameter would like to explain to me this rule or why it appears. If I see it, it should match the img tag, the first print can understand the second, but I don"t understand the big god to confuse the rookie