c# - Need a regular expression for detecting simple math expressions -
i'm going validate simple math expressions such these:
a = 1 + 2 b = 2.2 = b + 5.5 = b - -5.5 = -1 + 2 = -2.4 = 3.5 / 0.2 + 1 = 3 * -2.1
note: operator precedence not important!
i try following expressions got nothing!!!
for digits: ^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$ operators: [-]|[+]|[*]|[/] variables: [a-z]+|[a-z]+
i put these expressions in c# string variables , used .net regex.matches(...)
find matches. got nothing!
this not great job regular expressions. if want evaluate true mathematical expression not able come regex can handle cases. carl norum said similar discussion why can't parse html regex.
Comments
Post a Comment