I am using java.util.regex.Pattern class to match a string in a Android program.
if(Pattern.matches("\{\{.*?}}", element.getValue())) {
...
} else {
...
}
And I got the following error.
Caused by: java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 8
{{.*?}}
I am using Android studio and Open JDK. To test the regex expression I wrote a simple program in Netbeans and it works fine. Netbeans also use openjdk.
System.out.println(Pattern.matches("\{\{.*?}}", "{{hello:sdf}}"));
Why the regular expression is giving an error in android project?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…