private static double?Parse(string question) { if (VariableExpression.IsMatch(question)) { KeyValuePair <string, double> variable = VariableExpression.Parse(question); MathExpression.AddVariable(variable.Key, variable.Value); return(variable.Value); } else if (PercentOfExpression.IsMatch(question)) { return(PercentOfExpression.Parse(question)); } else if (PercentOffExpression.IsMatch(question)) { return(PercentOffExpression.Parse(question)); } else if (MathExpression.IsMatch(question)) { return(MathExpression.Parse(question)); } else { return(null); } }
public static bool IsMatch(string expression) { if (!Regex.IsMatch(expression, REGEX_PATTERN)) { return(false); } int index = expression.IndexOf("=") + 1; string parsedExpression = expression.Substring(index).Trim(); return(MathExpression.IsMatch(parsedExpression)); }