这是我目前的解决方法:
var str = "testing123";
var pattern = /([a-z]*)([0-9]*)/g;
var args;
str.replace(pattern, function(){args = arguments; return arguments[0];});
trace(args);
输出:
testing123,testing,123
但它想这样做:
var str = "testing123";
var pattern = /([a-z]*)([0-9]*)/g;
str.match(pattern);
trace(arguments);
这可能吗?
答案 0 :(得分:2)
var str = "testing123";
var pattern = /([a-z]*)([0-9]*)/g;
var hits:Object = pattern.exec (str);
for( var i:String in hits ) {
trace( i + " "+ hits[i] );
}
//outputs
0 testing123
1 testing
2 123
input testing123
index 0