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?
You can try escaping your
}: –I have no idea why it doesn’t work in
android, but inJavait works finewithout escapingit.However, if you are using an opening curly braces, then even in Java you would need to escape it: –