title: How to split by commas that are not within parentheses?
body: <p>Say I have a string like this, where items are separated by commas but there may also be commas within items that have parenthesized content:</p>
  
  <p>(EDIT: Sorry, forgot to mention that some items may not have parenthesized content)</p>
  
  <pre><code>"Water, Titanium Dioxide (CI 77897), Black 2 (CI 77266), Iron Oxides (CI 77491, 77492, 77499), Ultramarines (CI 77007)"
  </code></pre>
  
  <p>How can I split the string by only those commas that are NOT within parentheses? i.e:</p>
  
  <pre><code>["Water", "Titanium Dioxide (CI 77897)", "Black 2 (CI 77266)", "Iron Oxides (CI 77491, 77492, 77499)", "Ultramarines (CI 77007)"]
  </code></pre>
  
  <p>I think I'd have to use a regex, perhaps something like this:</p>
  
  <pre><code>([(]?)(.*?)([)]?)(,|$)
  </code></pre>
  
  <p>but I'm still trying to make it work.</p>