[code]var str = ‘abc123def345’;
var args = ;
str = str.replace(/\d+/g, function(){
console.log(arguments);
args.push(Number(arguments[0]));
});
console.log(args);[/code]
得到结果:[code]/usr/local/bin/node test.js
{ ‘0’: ‘123’, ‘1’: 3, ‘2’: ‘abc123def345’ }
{ ‘0’: ‘345’, ‘1’: 9, ‘2’: ‘abc123def345’ }
[ 123, 345 ][/code]