Hello I am currently trying to split the string "EAM\test" between the \ part. I have gotten the code to work if the \ was a -. But I can't see why the error is occuring
I have tried
String test = "EAM-testing";
String[] parts = test.split("-");
System.out.println("parts[0] = " + parts[0]);
System.out.println("parts[1] = " + parts[1]);
String test1 = "EAM\testing";
String[] parts1= test1.split("\\");
System.out.println("parts1[0] = " + parts1[0]);
System.out.println("parts1[1] = " + parts1[1]);
The output I see is:
parts[0] = EAM
parts[1] = testing
java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
\
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.lang.String.split(Unknown Source)
at java.lang.String.split(Unknown Source)
The error occurs at line: String[] parts1= test1.split("\\");