Here's a nifty little snippet of code that might get you what you need, it should cover most scenario in case the string you intend to parse has different number of arguments:
function parse (a)
{
var b={};
for (var i in a = a.match(/(w+((-?d+.?d*e?-?d*,?)+))+/g))
{
var c = a[i].match(/[w.-]+/g);
b[c.shift()] = c;
}
return b;
}
Running this
parse('translate(6,5),scale(3,3.5),a(1,1),b(2,23,-34),c(300)');
Will result in this:
{
translate: [ '6', '5' ],
scale: [ '3', '3.5' ],
a: [ '1', '1' ],
b: [ '2', '23', '-34' ],
c: [ '300' ]
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…