ex1 , [ex2 , ex3 ] , ex 4 , ex 4, [ex , ex ]
Unclosed character class near index 10
In Java character classes,
] symbol (inside the character class).
String pat = ",(?![^\\*])"; ^^
Here is an IDEONE demo:
String s = "ex1 , [ex2 , ex3 ] , ex 4 , ex 4, [ex , ex ]"; String pat = ",(?![^\\*])"; String result = s.split(pat); System.out.println(Arrays.toString(result));
Note that neither in Java, nor in JS, the
], outside the character class, does not have to be escaped.