I'm searching a way to check if a String is a mathematical expression as i.e.
x + y -sin(1) * 99k
i don't wanna evaluate the expression, but understand if the String is written in the right way.
There is some Java library for do that?
UPDATE: I'm sorry, is not an equation but only an expression (nothing '='). I have think about a possible solution:
- Specify the variables used
- replace all the variables with '1'
- evaluate the new String with JEval
- if the program raise an Exception, the expression is wrong
What you think about that?
Thanks