title: Javascript Regx on URL with certain pattern to extract certain parameter
body: <p>I have the following problem statement for pure vanilla javascript.</p>
  <p>From following different kinds of a URL pattern, extract the value of A, B &amp; C if present without &quot;XX&quot; value where A, B, C is the static word and appear in URL in diff. position.</p>
  <pre><code>abc.com/fld1/fld2/fld3/A:XX/B:XX/C:XX  - output will be &quot;&quot; (emtpy string as value XX)
  
  abc.com/fld1/fld2/fld3/A:XddX/B:XX/C:we33  - output will be &quot;XddX,we33&quot;
  
  abc.com/fld1/fld2/A:dd,rr,tt/B:ssww,ddd/C:kdkd,dd,d1d  - output will be &quot;dd,rr,tt,ssww,ddd,kdkd,dd,d1d&quot;
  
  abc.com/fld1/fld2/A:dd,rr,tt/C:kdkd,dd,d2d - output will be &quot;dd,rr,tt,kdkd,dd,d2d&quot;
  
  abc.com/fld1/fld2/C:deedd,rdr,t4dadt/B:kddkd,ddd,8udu - output will be &quot;deedd,rdr,t4dadt,kddkd,ddd,8udu&quot;
  
  abc.com/fld1/fld2/C:dd,rr,tt/A:kdkd,d5d,dd6 - output will be &quot;dd,rr,tt,kdkd,d5d,dd6&quot;
  
  abc.com/fld1/fld2/C:dd - output will be 'dd' 
  
  abc.com/fld1/fld2/fld3/B:dddd - output will be 'dddd'
  </code></pre>
  <p>I tried following pattern but not sure if I can use nagate to excldue &quot;XX&quot; value or better way to extact values.</p>
  <pre><code>/(A:)(\w+(,\w+)*)|(B:)(\w+(,\w+)*)|(C:)(\w+(,\w+)*)/ig;
  </code></pre>