Here's how I do it:
function getAndIncrementLastNumber(str) {
return str.replace(/\d+$/, function(s) {
return ++s;
});
}
Fiddle
Or also this, special thanks to Eric:
function getAndIncrementLastNumber(str) {
return str.replace(/\d+$/, function(s) {
return +s+1;
});
}
Fiddle