split("\\") and error

java

Solution

it should be

String[] strArray = str.split("\\\\");

the reason why is because in `Regex`, `\` has special meaning so you need to escape it into `\\`.

and in java, `\\` should be equal to `"\\\\"`

Problem

``` String str = "\u0054\u0068\u0069\u006e\u006b\u0050\u0061\u0064"; String[] strArray = str.split("\\"); ``` but this error occured. Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1

Original source