Android | Syntax Error in regexp pattern
android, java, regex
Solution
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
Problem
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 regex looks fine. but in Android Test Project I am getting this following error. ``` java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 7: \.(.*)} ^ at java.util.regex.Pattern.compileImpl(Native Method) at java.util.regex.Pattern.compile(Pattern.java:400) at java.util.regex.Pattern.<init>(Pattern.java:383) at java.util.regex.Pattern.compile(Pattern.java:367) ``` What is the problem?