Update: It's not duplicate with Regex to match only commas not in parentheses? because it matches commas in the string, but I want to split the string by commas and not to find the commas
My Test String
String myString = "x1, x2, x3, x4, x1(x1, x2,x3,x4)";
My Desired Output
x1
x2
x3
x4
x1(x1, x2,x3,x4)
I've just read How do I split a string by commas except inside parenthesis, using a regular expression? answer, but when I try to get it to Java error occurs
I try this:
String[] parts = myString.split("((?:[^,(]+|(\((?>[^()]+|\g<-1>)*\)))+)");
Error: Illegal escape character in string literal
What should I do?