Home >Web Front-end >JS Tutorial >Replace image address img tag with regular expression_Basic knowledge
The solution I initially thought of is:
The output result is:
What I get is the entire img tag, but what I expect is the URL in src, so I just need to return the new address in function(match).
So, I’m stuck here. . .
Later, I searched Google for the keyword "javascript replace callback" and found "replace callback function with matches" in stackoverflow, and then I learned that function (match) has other parameters
Then, change to the code below and the problem will be solved.
Output result: