title: How to split a string by commas positioned outside of parenthesis?
body: <p>I got a string of such format: </p>
  
  <pre><code>"Wilbur Smith (Billy, son of John), Eddie Murphy (John), Elvis Presley, Jane Doe (Jane Doe)"
  </code></pre>
  
  <p>so basicly it's list of actor's names (optionally followed by their role in parenthesis). The role itself can contain comma (actor's name can not, I strongly hope so).</p>
  
  <p>My goal is to split this string into a list of pairs - <code>(actor name, actor role)</code>. </p>
  
  <p>One obvious solution would be to go through each character, check for occurances of <code>'('</code>, <code>')'</code> and <code>','</code> and split it whenever a comma outside occures. But this seems a bit heavy...</p>
  
  <p>I was thinking about spliting it using a regexp: first split the string by parenthesis:</p>
  
  <pre><code>import re
  x = "Wilbur Smith (Billy, son of John), Eddie Murphy (John), Elvis Presley, Jane Doe (Jane Doe)"
  s = re.split(r'[()]', x) 
  # ['Wilbur Smith ', 'Billy, son of John', ', Eddie Murphy ', 'John', ', Elvis Presley, Jane Doe ', 'Jane Doe', '']
  </code></pre>
  
  <p>The odd elements here are actor names, even are the roles. Then I could split the names by commas and somehow extract the name-role pairs. But this seems even worse then my 1st approach.</p>
  
  <p>Are there any easier / nicer ways to do this, either with a single regexp or a nice piece of code? </p>