title: Javascript split by spaces but not those in quotes
body: <p>The goal is to split a string at the spaces but not split the text data that is in quotes or separate that from the adjacent text. </p>
  
  <p>The input is effectively a string that contains a list of value pairs. If the value value contains a space it is enclosed in quotes. I need a function that returns an array of value-pair elements as per the example below:</p>
  
  <p>Example Input: </p>
  
  <p><strong>'a:0 b:1 moo:"foo bar" c:2'</strong></p>
  
  <p>Expected result:</p>
  
  <p><strong>a:0,b:1,moo:foo bar,c:2</strong> (An array of length 4)</p>
  
  <p>I have checked through a load of other questions but none of them (I found) seem to cope with my issue. Most seem to split at the space within the quotes or they split the 'moo:' and 'foo bar' into separate parts.</p>
  
  <p>Any assistance would be greatly appreciated,
  Craig</p>