标签: javascript regex
我有一个字符串
var str3 = "[a,b,c] there [s,b,c] how are u";
我想要的是[there, how are u],但是与["", "how are u"]拆分时我得到了str3.split(/\[.*\]/);
[there, how are u]
["", "how are u"]
str3.split(/\[.*\]/);
有人知道我该怎么做吗?
答案 0 :(得分:0)
您不应贪婪:
str3.split(/\[.*?\]\s*/);
:-)