If I have the string:
var myStr = \"foo_0_bar_0\";
and I guess we should have a function called getAndIncrementLastNumber(str)
getAndIncrementLastNumber(str)
in regex try this:
function getAndIncrementLastNumber(str){ var myRe = /\d+[0-9]{0}$/g; var myArray = myRe.exec(str); return parseInt(myArray[0])+1; }
demo : http://jsfiddle.net/F9ssP/1/