Reputation: 10791
I have the following code. I would like to adapt the current regex /wid=\d+(\.\d)*/g
so that it matches wid=100&crop=0,0,960,650
and not just wid=100
. How can I adapt it to do this?
HTML
<img class="image-resize" src="http://hugoboss.scene7.com/is/image/hugoboss/test%2Dimg?wid=100&crop=0,0,960,650" name="mainimg" id="mainimg"/>
JQUERY
var regx = /wid=\d+(\.\d)*/g;
currentWidth = src.match(regx);
newWidth = 'wid=960&crop=0,0,960,650';
newSrc = src.replace(currentWidth, newWidth);
Upvotes: 0
Views: 53
Reputation: 30995
You can use this regex.
wid=.*?(?=")
As skamazin pointed in the comment you could achieve the same by using below regex (it could improve the readability):
wid=.*?"
Upvotes: 2