title: Split a string by commas but ignore commas within double-quotes using Javascript
body: <p>I'm looking for <code>[a, b, c, "d, e, f", g, h]</code>to turn into an array of 6 elements: a, b, c, "d,e,f", g, h. I'm trying to do this through Javascript. This is what I have so far:</p>
  
  <pre><code>str = str.split(/,+|"[^"]+"/g); 
  </code></pre>
  
  <p>But right now it's splitting out everything that's in the double-quotes, which is incorrect.</p>
  
  <p>Edit: Okay sorry I worded this question really poorly. I'm being given a string not an array.</p>
  
  <pre><code>var str = 'a, b, c, "d, e, f", g, h';
  </code></pre>
  
  <p>And I want to turn <em>that</em> into an array using something like the "split" function.</p>