I am using \\\\.(.*)} regex pattern to search a specific string in my Android Test Project. when i am using this regex to check on online available tools the re
I was facing the same problem. I just surround it with a
try{
}catch (PatternSyntaxException e) {
e.printStackTrace();
}
and it worked.
You need to escape } as @Rohit Jain said:
String regex = "\\.(.*)\\}";
Your regex does work in java, but it fails on android for some reason.
You can try escaping your }: -
"\\.(.*)\\}" // escaping `}` not needed in Java
I have no idea why it doesn't work in android, but in Java it works fine without escaping it.
However, if you are using an opening curly braces, then even in Java you would need to escape it: -
"\\.(.*)\\{" // escaping `{` needed even in Java