title: Regex Pattern to Parse the formula bar
body: <p>I am implementing the formula bar in which there can be any operation with two values like:</p>
  
  <pre><code>SUB ( DIV ( ADD (2,5), 4.5 ), AVG (3,4) )
  </code></pre>
  
  <p>So here I need to first call <code>ADD</code> operation as its most inner operation, then <code>DIV</code> it by some fraction, then calculate the <code>AVG</code> and in last <code>SUB</code> both the values, so there can be any formula user can put on formula bar.</p>
  
  <p>I am trying to write recursive function for that but before that I need to parse it properly. I could not figure out how to write regex for this kind of pattern.. </p>
  
  <p>Any ideas please?</p>