jQuery/JavaScript Split String by Commas that are Outside of Parenthesis
<p>I am using jQuery &amp; JavaScript!!</p>

<p>I have a string, for example </p>

<pre><code>"cubic-bezier(0.25, 0, 0.25, 1), ease-in, ease-out, linear"
</code></pre>

<p>..and I want to split it into this array:</p>

<pre><code>// (the following has no leading or trailing spaces:)

Array[4]
  0: cubic-bezier(0.25, 0, 0.25, 1)
  1: ease-in
  2: ease-out
  3: linear
</code></pre>

<p>..but instead I get:</p>

<pre><code>Array[7]
  0: cubic-bezier(0.25
  1: 0
  2: 0.25
  3: 1)
  4: ease-in
  5: ease-out
  6: linear
</code></pre>

<p>I have attempted a dozen solutions, only to find that any way that I try it doesn't work thus far. Here are a few of my previous attempts:</p>

<pre><code>var myString = "cubic-bezier(0.25, 0, 0.25, 1), ease-in, ease-out, linear";

myString.split(",(?![^\(\)]*&gt;)");

myString.split('(?:\(.*?\))|(,)');

myString.split(",(?=[^\]]*(?:\[|$))");

myString.split(",(?![^()]*(?:\([^()]*\))?\))");

myString.split('/,(?![^()]*(?:\([^()]*\))?\)/g');

myString.split(",(?=(([^']*'){2})*[^']*$)(?=(([^\"]*\"){2})*[^\"]*$)(?![^()]*\\))");
</code></pre>

<p>I am familiar with basic regex rules, such as capture groups and selectors, but am still confused on lookaheads or how I would solve my current situation.</p>