title: How to get string in nested parenthesis or square brackets by separately
body: <p>I have textbox which user write the formula as mathematical. For example user's input is <code>((a+b) + c)</code> so how can I get the string by separately in parenthesis </p>
  
  <pre><code>var txt = "((a+b) + c)";
  var newTxt = txt.split('(');
  for (var i = 1; i &lt; newTxt.length; i++) {
      var value = newTxt[i].split(')')[0];
      console.log(value);
  }
  </code></pre>
  
  <p>In this example I get only <code>a+b</code> but I'm trying to get strings separetely for example output like this</p>
  
  <pre><code>a+b
  
  (a+b)+c
  </code></pre>