i want to replace all the src attribute inside a string of HTML adding a '?a' at the end of the url to fix a caching issue that i'm having.
So far i got this:
str.replace(/src=".*?"/gi, "src");
But i have no idea how to do the 2nd parameter to get what is matched and add the '?a' at the end.
Example:
<img src="mysite.com/logo.png" /> should become
<img src="mysite.com/logo.png?a" />
Thank you in advance, Daniel!

.replace(/src="(.*?)"/gi, 'src="$1?a"');