我有一个看起来像这样的字符串:
Birds(Parrort, cockatoo, Sparrow, KingFisher, Peacock), Big Dogs, Big Cats, Reptiles(Crocodile)
我想将此字符串的每个部分拆分为类似
的字符串Birds(Parrort, cockatoo, Sparrow, KingFisher, Peacock)
Big Dogs
Big Cats
Reptiles(Crocodile)
提前致谢!
答案 0 :(得分:1)
答案 1 :(得分:0)
尝试另一种方法:
将字符串更改为:
Birds(Parrort, cockatoo, Sparrow, KingFisher, Peacock)|Dogs|Cats|Reptiles(Crocodile)
使用:
var str = "Birds(Parrort, cockatoo, Sparrow, KingFisher, Peacock)|Dogs|Cats|Reptiles(Crocodile)";
var res = str.split("|");
答案 2 :(得分:0)
var str = 'Birds(Parrort, cockatoo, Sparrow, KingFisher, Peacock),Dogs, Cats, Reptiles(Crocodile)';
var array = str.split(", (?![^(]*\\))");
console.log(array);