I have a string like this:
String str = "[a,b,c,d],[1,2,3,4],[a,gf,d,cvb],[4,3,2,1]";
I want to split this string into four parts, like this:
[a,b,c,d]
[1,2,3,4]
[a,gf,d,cvb]
[4,3,2,1]
I tried this:
List<String> splitWords = Arrays.asList(str.split("\\],\\["));
When I use this, I get following strings:
[a,b,c,d
1,2,3,4
a,gf,d,cvb
4,3,2,1]
In this case, I also remove brackets next to commas, but I don't want to do that. What is the regex for my problem?