var str = "matrix(1, 0, 0, 1, -500, 0)";
var reg = /([^,]+),[^,]+\)$/g;
console.time("111");
console.log(reg.exec(str)[1]);
console.timeEnd("111");
/**
* n=0 获取函数名
* n>0 获取函数参数
*/
function findParam(str,n){
var len = str.length;
var count = 0;
var ret = '';
for(var i=0;i<len;i++){
if(str[i]==','||str[i]==')'||str[i]=='('){
if(++count==n+1) return ret;
}else if(count==n){
ret += str[i];
}
}
return ret;
}
console.time("222");
console.log(findParam(str,5));
console.timeEnd("222");