title: Using RegEx in Java, how do I capture groups delimited by double pipes excluding those enclosed by double quotes?
body: <p>Example:</p>
  
  <pre><code>abc | efg || $something("arg 1", "arg 2||(a|b)") || 123
  </code></pre>
  
  <p>or without whitespace</p>
  
  <pre><code>abc|efg||$something("arg 1", "arg 2||(a|b)")||123
  </code></pre>
  
  <p>What RegEx pattern is needed so that I can get the following groups:</p>
  
  <pre><code>abc | efg
  $something("arg 1", "arg 2||(a|b)")
  123
  </code></pre>
  
  <p>Total of 3 groups.</p>
  
  <p>Another example:</p>
  
  <pre><code>"abc || efg" || 123
  </code></pre>
  
  <p>Should give me 2 groups</p>
  
  <pre><code>"abc || efg"
  123
  </code></pre>
  
  <p>Basically it cuts or splits the string by double pipes but excluding double pipes within double quotes.</p>
  
  <p>My failed attempts are the following:</p>
  
  <p>.+?(?=\|\|)|.*</p>
  
  <p>\".+?\"|.+?(?=\|\|)|.*</p>