I hate Regex. The following Java code runs fine in Eclipse.
In B4A
I get.
Not too surprising that i get the same thing in a library. So why the difference?
B4X:
public static void main(String[] args) {
// TODO Auto-generated method stub
final Pattern validstatement = Pattern.compile("^\\s*\\{?\\s*(\\?\\s*=)?\\s*call\\s*([\\w.]+)(\\(.*\\))?\\s*}?", Pattern.CASE_INSENSITIVE);
Matcher m = validstatement .matcher("{ call order(?, ?) }");
if(m.matches()) {
System.out.println("Valid");
} else {
System.out.println("Invalid");
}
}
}
}
In B4A
B4X:
Regex.IsMatch("^\\s*\\{?\\s*(\\?\\s*=)?\\s*call\\s*([\\w.]+)(\\(.*\\))?\\s*}","{ call order(?,?) }")
I get.
B4X:
java.util.regex.PatternSyntaxException: Error in {min,max} interval near index 9:
^\\s*\\{?\\s*(\\?\\s*=)?\\s*call\\s*([\\w.]+)(\\(.*\\))?\\s*}
^
at java.util.regex.Pattern.compileImpl(Native Method)
at java.util.regex.Pattern.compile(Pattern.java:411)
at java.util.regex.Pattern.<init>(Pattern.java:394)
at java.util.regex.Pattern.compile(Pattern.java:374)
at anywheresoftware.b4a.keywords.Regex.getPattern(Regex.java:34)
at anywheresoftware.b4a.keywords.Regex.IsMatch2(Regex.java:60)
at anywheresoftware.b4a.keywords.Regex.IsMatch(Regex.java:53)
at b4a.example.main._activity_create(main.java:341)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at b4a.example.main.afterFirstLayout(main.java:100)
at b4a.example.main.access$100(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:78)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Not too surprising that i get the same thing in a library. So why the difference?