\"http://something.com:6688/remote/17/26/172\"
if I have the value 172 and I need to change the url to 175
\"http://something.com:6688/
Split the String by / then change the last part and rejoin by /:
/
var newnumber = 175; var url = "http://something.com:6688/remote/17/26/172"; var segements = url.split("/"); segements[segements.length - 1] = "" + newnumber; var newurl = segements.join("/"); alert(newurl);
Try it!