title: r split on delimiter not in parentheses
body: <p>I am currently trying to split a string on the pipe delimiter: </p>
  
  <pre><code>999|150|222|(123|145)|456|12,260|(10|10000)
  </code></pre>
  
  <p>The catch is I don't want to split on <code>|</code> inside of parentheses, I only want to split on this character outside of parentheses.</p>
  
  <p>This is just splitting on every <code>|</code> character, yielding the results I don't want:</p>
  
  <pre><code>x &lt;- '999|150|222|(123|145)|456|12,260|(10|10000)'
  m &lt;- strsplit(x, '\\|')
  
  [[1]]
  [1] "999"    "150"    "222"    "(123"   "145)"   "456"    "12,260" "(10"   
  [9] "10000)"
  </code></pre>
  
  <p>I am looking to get the following results keeping everything inside of parentheses:</p>
  
  <pre><code>[[1]]
  [1] "999"        "150"        "222"        "(123|145)"  "456"       
  [6] "12,260"     "(10|10000)"
  </code></pre>
  
  <p>Any help appreciated.</p>