ezylang / EvalEx

EvalEx is a handy expression evaluator for Java, that allows to evaluate simple mathematical and boolean expressions.
https://ezylang.github.io/EvalEx/
Apache License 2.0
977 stars 265 forks source link

does not evaluate if expression operand has a period, hyphen seperater #494

Open Manan-13 opened 1 month ago

Manan-13 commented 1 month ago

"{airQuality.temperature} > 44"

Map<String, Object> values = new HashMap<>(); values.put("a-b", "indoor"); EvaluationValue result = e.withValues(values).evaluate();

BaseException(startPosition=4, endPosition=5, tokenString=a, message=Variable or constant value for 'a' not found) at Main.main(Main.java:24) Caused by: BaseException(startPosition=4, endPosition=5, tokenString=a, message=Variable or constant value for 'a' not found)

Any workaround for this ?

stevenylai commented 1 month ago

dot (.) and hyphen (-) are reserved operators from the library. I would suggest you replace those special characters with underscore (_) when creating expressions and passing in variables.