title: Evaluate math expression in c# that should handle whitespace if it exists
body: <p>I am trying to use the following code to evaluate math expression. currently, the expression parser only works if there is a whitespace between every character. ex: (x + y) *2.... if the expression is (x+y)*2, the expression does not evaluate. Trying to use regex so the expression evaluates with or without spaces,but still unable to meet the goal. Any direction/help is greatly appreciated.</p>
  
  <pre><code>using System;
  using System.Text.RegularExpressions;
  
  public class Example
  {
     public static void Main()
     {
        string input = "(x + y)*2";
        string pattern = "\\s+";
        string replacement = " ";
        Regex rgx = new Regex(pattern);
        string result = rgx.Replace(input, replacement);
  
        Console.WriteLine("Original String: {0}", input);
        Console.WriteLine("Replacement String: {0}", result);                             
     }
  }
  </code></pre>