jquery - Regext to match part of a string -


i have following code. adapt current regex /wid=\d+(\.\d)*/g matches wid=100&crop=0,0,960,650 , not wid=100. how can adapt 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); 

you can use regex.

wid=.*?(?=") 

working demo

enter image description here

as skamazin pointed in comment achieve same using below regex (it improve readability):

wid=.*?" 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -