As galets says, I don't think your solution is a bad one but here is a function that will add a specified value to a number in a specified position in a string.
var str = "fluff (3) stringy 9 and 14 other things";
function stringIncrement( str, inc, start ) {
start = start || 0;
var count = 0;
return str.replace( /(\d+)/g, function() {
if( count++ == start ) {
return(
arguments[0]
.substr( RegExp.lastIndex )
.replace( /\d+/, parseInt(arguments[1])+inc )
);
} else {
return arguments[0];
}
})
}
// fluff (6) stringy 9 and 14 other things :: 3 is added to the first number
alert( stringIncrement(str, 3, 0) );
// fluff (3) stringy 6 and 14 other things :: -3 is added to the second number
alert( stringIncrement(str, -3, 1) );
// fluff (3) stringy 9 and 24 other things :: 10 is added to the third number
alert( stringIncrement(str, 10, 2) );