title: use python regex to find key=value pairs separated by comma but keep quoted portion together
body: <p>How do you get the key, value pair from following string:</p>
  
  <pre><code>s='pairs=&lt;A=name,B=2,C="Last, First"&gt;'
  </code></pre>
  
  <p>the part within the brackets &lt; ... > contains K=V pairs, which are separated by commas. The value part could have commas in quotes.</p>
  
  <p>My clunky solution is to get the portion between bracket, find positions of comma that is not in quotes, substring by found comma positions, then split key / value by '=', and turn the whole thing to a dict.</p>
  
  <p>regex should be able to do this in much straightforward way, right?</p>
  
  <p>I got to this far:</p>
  
  <pre><code>re.findall('([A-Z]+[0-9]*)=([^,]*)', s)
  </code></pre>
  
  <p>but result did not turn out to be right:</p>
  
  <pre><code>[('A', 'name'), ('B', '2'), ('C', '"Last')]
  </code></pre>
  
  <p>How to ignore the commas in the quotes?</p>
  
  <h2>EDIT</h2>
  
  <p>I made a mistake. My original regex pattern should not have worked, if the key can have lower case letter. </p>
  
  <p>I took that into consideration, and combined and eph and vks' solutions: </p>
  
  <pre><code>s='Pairs=&lt;Aa=name,Bb=2,Cc="Last, First"&gt;'
  re.findall('([A-Za-z]+[0-9]*)=("[^"]*"|[^,]*)', re.findall(r"&lt;([^&gt;]*)&gt;",s)[0]) 
  </code></pre>
  
  <p>and it seems to work. </p>
  
  <p>Improvement upon this solution?</p>