Ask the regular boss to take a look at this for me. I don't get it.

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

.

match: overall matching value
capture: ([^'"] +) is printed. The first answer in the first tuple


is the complete result of the global match, and the second is the matching result after grouping in parentheses. Parentheses are used to group the matching results!


clipboard.png
this should make it easy for you to understand one of the functions of ~


parentheses and capture packets. reference link


this article should be understood. This is my previous summary


followed by gi g is global, what is I?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c50d-2b668.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c50d-2b668.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?