title: Use regular expression to handle nested parenthesis in math equation?
body: <p>If I have:</p>
  
  <pre><code>statement = "(2*(3+1))*2"
  </code></pre>
  
  <p>I want to be able to handle multiple parentheses within parentheses for a math reader I'm writing. Perhaps I'm going about this the wrong way, but my goal was to recursively go deeper into the parentheses until there were none, and then I would perform the math operations. Thus, I would first want to focus on </p>
  
  <pre><code>"(2*(3+1))" 
  </code></pre>
  
  <p>then focus on </p>
  
  <pre><code>"(3+1)"
  </code></pre>
  
  <p>I hoped to do this by assigning the focus value to the start index of the regex and the end index of the regex. I have yet to figure out how to find the end index, but I'm more interested in first matching the regex</p>
  
  <pre><code>r"\(.+\)" 
  </code></pre>
  
  <p>failed to match. I wanted it to read as "any one or more characters contained within a set of parentheses". Could someone explain why the above expression will not match to the above statement in python?</p>