I have a requiremnt where a mathematical expression is embedded in an apex string variable and I need to evaluate that expression value. Is there any way to do this? Any workaround for this? Thanks in advance.


1 Answer 1


No, apex does not have a way to evaluate a string at runtime. You could write your own parser, but it wouldn't be easy. You'd have to find a way to do this in JavaScript if your logic has any sort of UI/page layer.

Here are a few examples from questions asked here previously: Evaluate expressions/conditions in apex code ? (which are stored in string/text)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .