regex - regular expression to evaluate or validate expression entered by user in C# -


I want to split the sensible / relational / logical expression that the user uses Reggae so that at run-time I can evaluate the expression recorded by the user below, some example expressions have been recorded by the user.

  Expression 1: (a == b & amp; amp; (c> = 10 || d! = 0)) || (A and G; B) Expression 2: (C == D & amp; A = A = B)  

Now I want to separate the whole expression in string array for example Take the expression 2 and it will be like

  string str1 = c == d; Str2 = a = b =;  

There may be several situations of expression that the user enters and therefore there is no information to proceed.

Thanks

Regular expression is not the right tool for this task.

If you want to be able to evaluate arbitrarily expressions, then you have a simple form of at least one parser.

In the past I have used simple expression evaluation functions. It's really easy to use, supports all you used in the box and you can also use it.

There are other libraries available, this is just an example. You can also apply yourself a parser, but in your opinion it can be more difficult.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -