title: How to match comma outside multiple parentheses by regex
body: <p>I split a string by comma, but not within parathesis, using <code>preg_split</code>. I came up with</p>
  <pre><code>preg_split('#,(?![^\(]*[\)])#',$str);
  </code></pre>
  <p>which works perfectly unless there is a comma before a nested parenthesis.</p>
  <p>Works for</p>
  <pre><code>$str = &quot;first (1,2),second (child (nested), child2), third&quot;;
  
  Array
  (
      [0] =&gt; first (1,2)
      [1] =&gt; second (child (nested), child2)
      [2] =&gt;  third
  )
  </code></pre>
  <p>but not for</p>
  <pre><code>$str = &quot;first (1,2),second (child, (nested), child2), third&quot;;
  
  Array
  (
      [0] =&gt; first (1,2)
      [1] =&gt; second (child
      [2] =&gt;  (nested), child2)
      [3] =&gt;  third
  )
  </code></pre>