[Solved] Please help me on this javascript [closed]


You need to match the number inside with something like:

replace(/\/s[0-9]+\//, '/s' + image_size + "https://stackoverflow.com/")

Here’s an example: http://jsfiddle.net/nfDea/

Another option is to capture the beginning and end only, in order to concatenate:

replace(/(\/s)[0-9]+(\/)/, "$1" + image_size + "$2");

http://jsfiddle.net/nfDea/1/

If you are actually referring to a variable called uh, then you need to use the following:

var re = new RegExp("/s(" + uh + ")/");
a = a.replace(re, "/s" + image_size + "https://stackoverflow.com/");

http://jsfiddle.net/nfDea/4/

or

var re = new RegExp("(/s)" + uh + "(/)");
a = a.replace(re, "$1" + image_size + "$2");

http://jsfiddle.net/nfDea/3/

1

solved Please help me on this javascript [closed]