Javascript get query string values using non-capturing group

Given this query string:

?cgan=1&product_cats=mens-jeans,shirts&product_tags=fall,classic-style&attr_color=charcoal,brown&attr_size=large,x-small&cnep=0

How can I extract the values from only these param types 'product_cat, product_tag, attr_color, attr_size'

returning only 'mens-jeans,shirts,fall,classic-style,charcoal,brown,large,x-small

I tried using a non capturing group for the param types and capturing group for just the values, but its returning both.

(?:product_cats=|product_tags=|attrw+=)(w|,|-)+


Source: regex

Leave a Reply