请问,以下字符串如何拆分成数组,要求不能拆数组和对象:
const text = "a,b,c,[1,2,3],d,{a:1,b:2}"; const parseText = (text) => { //todo } parseText(text); //["a","b","c","[1,2,3]","d","{a:1,b:2}"];
// => ?["a", "b", "c", "[1,2,3]", "d", "张三", "{a:1,b:2}", "hello"] 'a,b,c,[1,2,3],d,张三,{a:1,b:2},hello,'.match(/(([.+])|{.+}|([^,]+))/g)
1.4m articles
1.4m replys
5 comments
57.0k users