title: using regex to split equations with variables C#
body: <p>I've been struggling with this for quite awhile (not being a regex ninja), searching stackoverflow and through trial an error. I think I'm close, but there are still a few hiccups that I need help sorting out. </p>
  
  <p>The requirements are such that a given equation, that includes variables, exponents, etc, are split by the regex pattern after variables, constants, values, etc. What I have so far   </p>
  
  <pre><code>     Regex re = new Regex(@"(\,|\(|\)|(-?\d*\.?\d+e[+-]?\d+)|\+|\-|\*|\^)");
       var tokens = re.Split(equation)
  </code></pre>
  
  <p>So an equation such as </p>
  
  <pre><code>    2.75423E-19* (var1-5)^(1.17)* (var2)^(1.86)* (var3)^(3.56)
  </code></pre>
  
  <p>should parse to </p>
  
  <pre><code>     [2.75423E-19 ,*, (, var1,-,5, ), ^,(,1.17,),*....,3.56,)]
  </code></pre>
  
  <p>However the exponent portion is getting split as well which I think is due to the regex portion: |+|-. </p>
  
  <p>Other renditions I've tried are:</p>
  
  <pre><code>    Regex re1 = new Regex(@"([\,\+\-\*\(\)\^\/\ ])"); and 
      Regex re = new Regex(@"(-?\d*\.?\d+e[+-]?\d+)|([\,\+\-\*\(\)\^\/\ ])");
  </code></pre>
  
  <p>which both have there flaws. Any help would be appreciated.</p>