I am trying to evaluate a pattern or regular based expression in Java using the MVEL library. However, the "matches" function is not working fine and is giving compilation error.
I have tried to create a an expression like below in MVEL but regular expression is not working fine.
Works Fine -
System.out.println(MVEL.eval("'5.00' == '5.00'"));
Answer : true
Does not work fine -
System.out.println(MVEL.eval("'5.00' matches '^-?\\d+(\\.\\d{2})?$'"));
Error Message :
Exception in thread "main" [Error: unexpected token or unknown identifier:matches]
[Near : {... '5.00' matches '^-?\d+(\.\d{2})?$' ....}]
^
[Line: 1, Column: 8]
at org.mvel2.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:138)
at org.mvel2.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:47)
at org.mvel2.MVEL.eval(MVEL.java:92)
at com.oracle.oci.ops.integrate.config.parser.MVELParser.main(MVELParser.java:24)
Can some one please help me out in resolving the issue?