求帮助分别取出四个值
1 回答
守候你守候我
TA贡献1802条经验 获得超10个赞
replace
+ split
'{"A":"5","B":"4","C":"3","D":"2"}'.replace(/(?:"[^"]+":)|["{}]/g,'').split(',') ["5", "4", "3", "2"]
split
str = '{"A":"5","B":"4","C":"3","D":"2"}';str.split(/(?:^\{|",)"[^"]+":"|"\}$/g).slice(1,-1) ["5", "4", "3", "2"]
简化~
str.split(/[{"][^:]+:"|"\}/g).slice(1,-1) ["5", "4", "3", "2"]
添加回答
举报
0/150
提交
取消