I get the name of an input element, which is a string with a number (url1). I want to increment the number by 1 (url2
url1
url2
You can use replace and pass it a function to use to replace the matched section:
str.replace(/\d+/, function(number) { return parseInt(number, 10) + 1; });