var re = /\d(\d)/g;
var str = '123';
var match;
var results = [];
while (match = re.exec(str)) {
results.push(+match[1]);
}
console.log(results);
Instead of [2, 3] as I would expect, it gives only [2] I cannot figure this out. Why doesn't the 23 match the regex and give the 3 as the capture group?