title: Javascript Regex comma separated text
body: <p><strong>I have this string:</strong></p>
  
  <p><code>remote:City|Vestavia Hills,AL,remote:Citystate|Vestavia Hills,395b5231539390675a7abe0751fc4820,remote:City|Vestavia Hills,AL,remote:Citystate|Vestavia Hills,395b5231539390675a7abe0751fc4820</code></p>
  
  <p>I want to match and extract strings separated with commas.</p>
  
  <p><strong>The result should be:</strong> </p>
  
  <pre><code>MATCH 1 
  'remote:City|Vestavia Hills,AL' 
  MATCH 2 
  'remote:Citystate|Vestavia Hills' 
  MATCH 3 
  '395b5231539390675a7abe0751fc4820' 
  MATCH 4 
  'remote:City|Vestavia Hills,AL' 
  MATCH 5 
  'remote:Citystate|Vestavia Hills' 
  MATCH 6 
  '395b5231539390675a7abe0751fc4820'
  </code></pre>
  
  <p><strong>I have this regex:</strong></p>
  
  <pre><code>(remote:[a-zA-Z]+\|[^\,]+|[a-f0-9]{32})
  </code></pre>
  
  <p>but those cities which have state 'AL' (separated with comma) are separated incorrectly.</p>
  
  <p><strong>Possible solution:</strong></p>
  
  <p>I was thinking of doing something like this - <code>remote:[a-zA-Z]+\|.*</code>  - and end match on the comma which have after it self (<code>remote:[a-zA-Z]+\|.*</code>) or md5 hash (<code>[a-f0-9]{32},?</code>).</p>
  
  <p>Here is my regex tester link:</p>
  
  <p><a href="https://regex101.com/r/rP8iJ2/1" rel="nofollow">https://regex101.com/r/rP8iJ2/1</a></p>