JS按中括号分割数组
要求:
字符串“[总体积]=[松土]+[普通土]+[硬土]”按中括号分割成数组
var a = "[总体积]=[松土]+[普通土]+[硬土]"; let regex = /\[(.+?)\]/g; a = a.match(regex); console.log(a);
结果:
["[总体积]", "[松土]", "[普通土]", "[硬土]"]
参考:
https://www.cnblogs.com/lalalagq/p/9898757.html
要求:
字符串“[总体积]=[松土]+[普通土]+[硬土]”按中括号分割成数组
var a = "[总体积]=[松土]+[普通土]+[硬土]"; let regex = /\[(.+?)\]/g; a = a.match(regex); console.log(a);
结果:
["[总体积]", "[松土]", "[普通土]", "[硬土]"]
参考:
https://www.cnblogs.com/lalalagq/p/9898757.html