I have a textfield, where a user can write a mathamatical expression which may include if-else block.
So, an expressions can be as follows,
a * b // here there is space between a and *
p+q // here there is no space between p and +
x+ y // here there is no space between x & + bu there in between + & y
(x+y)(x*y)
if(a>10){a+b}else if(b>10){b-a}else{a+b}
if( age>18 ){ a+90 }else{ a-90 } // spaces may present or not
if( married == "yes"){ total*0.1 } else{ total*0.2 } // spaces may present or not
These all above examples are valid expression.
I am trying to validate all these types of expression with single regular expression. How a regular expression look like in JavaScript?
Thank you :)