split里使用正则分割带分组
比如:
let a = '{a1}{b2}{c3}';
let strings = a.split(/{(\w\d)}/g); // 结果1为: ["", "a1", "", "b2", "", "c3", ""]
let strings = a.split(/({\w\d})/g); // 结果2为: ["", "{a1}", "", "{b2}", "", "{c3}", ""]
为什么分割后结果是这样我看不懂......,一般split不是按匹配到的字符串分割的吗, 分割后匹配的字符串应该不存在啊,
比如 a.spit ('{a1}') 结果为 ["", "{b2}{c3}"]. 它是怎么分割的啊啊啊啊啊啊啊,老师,各位大佬求教?