问题描述:
将一个字符串:
"key1='value11,value12,value13',key2=value2,key3='value3',key4=value4"
提取成:
[
"key1='value11,value12,value13'",
"key2=value2",
"key3='value3'",
"key4=value4"
]
的形式。
var str = "key1='value11,value12,value13',key2=value2,key3='value3',key4=value4"; | |
var patt = /[^=,]+=('[^']*'|[^,]*)/g | |
var match; | |
var list = []; | |
while ((match = patt.exec(str))) { | |
list.push(match[0]); | |
} | |
console.log(list); |