I’ve been looking for an efficient way to do this but haven’t been able to find it, basically what I need is that given this url for example:
http://localhost/mysite/includes/phpThumb.php?src=http://media2.jupix.co.uk/v3/clients/4/properties/795/IMG_795_1_large.jpg&w=592&aoe=1&q=100
I’d like to be able to change the URL in the src parameter with another value using javascript or jquery, is this possible?
Wouldn’t this be a better solution?
EDIT:
added some clarity in code and kept ‘src’ in the resulting link
$1represents first part within the()(i.e)src=and$2represents the second part within the()(i.e)&, so this indicates you are going to change the value betweensrcand&. More clear, it should be like this:ADD-ON for replacing all the ocurrences:
If you have several parameters with the same name, you can append to the regex global flag, like this
text.replace(/(src=).*?(&)/g,'$1' + newSrc + '$2');and that will replaces all the values for those params that shares the same name.