I want split a string like this:
C:\Program\files\images\flower.jpg
but, using the following code:
String[] tokens = s.split("\\");
String image= tokens[4];
I obtain this error:
11-07 12:47:35.960: E/AndroidRuntime(6921): java.util.regex.PatternSyntaxException: Syntax error U_REGEX_BAD_ESCAPE_SEQUENCE near index 1:
try
In java(regex world)
\is a meta character. you should append with an extra \ or enclose it with \Q\E if you want to treat a meta character as a normal character.below are some of the metacharacters
to treat any of the above listed characters as normal characters you either have to escape them with ‘\’ or enclose them around \Q\E
like: