title: Handling math equation string with Regex
body: <p>I have an expression that always will fit this form:</p>
  
  <p>variable-25.6+thing</p>
  
  <p>This is a string input by the user. I want to parse out each token, excluding the operators. I though maybe a regex would be good for this, but it is harder than I expected it to be.</p>
  
  <p>I am using the javascript engine btw. Here is what I have so far.</p>
  
  <pre><code>/(\d+\.?\d+|\w+)(?:[\+\-\*\/])(\d+\.?\d+|\w+)/
  </code></pre>
  
  <p>This works for the following:</p>
  
  <p>variable
  variable+25.6
  25.6</p>
  
  <p>But, it fails if I expand to more than one operator:</p>
  
  <p>variable+25.6+other_variable+...</p>
  
  <p>I tried</p>
  
  <pre><code>/((\d+\.?\d+|\w+)(?:[\+\-\*\/]))+(\d+\.?\d+|\w+)/
  </code></pre>
  
  <p>so that the passive group could be repeated, however, it also matches</p>
  
  <p>variable+</p>
  
  <p>so I am not sure why it is matching the operator even though it is in a passive group.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>variable can be any text. It is just anything that matches the \w class. So, anything that is either a decimal (with or without the .) or a word can match. Any of the four operators can be between the variables/numbers. I just don't want operators to be captures, only verify that they are there.</p>