1

I want to develop a class/method that takes as input a string of this format: "((true | false) & (!false & false))", and returns true or false, accordingly (in this case false).

How should I proceed?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Endrit Sino
  • 113
  • 4

1 Answers1

3

if performance is not the issue AND you're really sure that the boolean expression is safe (security reasons), you can launch a full-blown JavaScript engine and evaluate the expression

like described in the following question.

Community
  • 1
  • 1
WeMakeSoftware
  • 9,039
  • 5
  • 34
  • 52
  • And [Here](http://stackoverflow.com/questions/10917878/evaluate-string-as-a-condition-java) another good example – Husam Nov 02 '15 at 13:58
  • Thank you Funtik! Actually I guess the performance will be an issue, for me. Adding just a small note, that might complicate a bit the problem, is that I am going to implement this in Salesforce(I don't know if you're familiar with), that uses Apex as the propietary language. Apex, is a Java-like language, and I thought that I could get a solution adaptable to Apex, but I appreciate your answer, so thank you. :) – Endrit Sino Nov 02 '15 at 14:08