How can I parse a string from user input and rebuild it into a javascript conditional statement.
For example, if the user inputs the follwing string into a texbox
x==1 && y==2 || (z!=3)
How can I recreate this string to execute the following server side javascript
if (vars['x'] == 1 && vars['y'] == 2 || (vars['z'] != 3))
My app is built on node.js if that info helps at all. I am aware of the eval() function, but I need to grab the variables from the user expression first, before evaluation.
This seems too complicated for regular expressions. If anyone knows of a simple parser that would accomplish something like this that would be great.