MultiRegExp is a javascript regular expression extension which allows the capture of index values in addition to the strings normally returned from capture groups. It does this by inserting capture groups between all groups in the original regular expression and computing the index of the original groups using the lengths of all preceding matched groups. The git repo can be found here.
var exp = new MultiRegExp(/([a-z]+)(?:\s|_)*([0-9]+)/i);
exp.exec("test_53"); //will return {0: {index:0, text:'test'}, 1: {index:5, text:'53'}}