title: PowerShell: Splitting by comma unless in quotes
body: <p>I'm trying to parse a string splitting on commas except when comma is inside quotes:</p>
  <pre class="lang-bash prettyprint-override"><code>$teststring = 'Data1,Data2,&quot;Data 3, more&quot;, Data 4'
  $tempsting = $null
  $tempsting = $teststring -split ',(?=([^\&quot;]*\&quot;[^\&quot;]*\&quot;)*[^\&quot;]*$)'
  
  Write-Host $teststring
  $i =0 
  
  Foreach ($object in $tempsting) {
      Write-Host $i &quot; &quot; $tempsting[$i]
      #Write-Host $tempsting[$i]
      $i++
  }
  </code></pre>
  <p>Outputs this:</p>
  <pre class="lang-none prettyprint-override"><code>Data1,Data2,&quot;Data 3, more&quot;, Data 4
  0   Data1
  1   Data2,&quot;Data 3, more&quot;
  2   Data2
  3   &quot;Data 3, more&quot;
  4   &quot;Data 3, more&quot;
  5    Data 4
  </code></pre>
  <p>What I want is this:</p>
  <pre class="lang-none prettyprint-override"><code>Data1,Data2,&quot;Data 3, more&quot;, Data 4
  0   Data1
  1   Data2
  2   &quot;Data 3, more&quot;
  3   Data 4
  </code></pre>