I'm trying to figure out how I can repeat a capture group on the comma-separated
values in this the following url string:
id=1,2;name=user1,user2,user3;city=Oakland,San Francisco,Seattle;zip=94553,94523;
I'm using this RegExp
which is return results I want, except for the values since they're dynamic ie. could be 2,3,4,etc users in the url parameter and was wondering if I could create a capture group for each value instead of user1,user2,user3
as one capture-group.
RegExp: (^|;|:)(\w+)=([^;]+)*
Here is a live demo of it online using RegExp
Example Output:
- Group1 - (semi-colon,colon)
- Group2 - (key ie. id,name,city,zip)
- Group3 - (value1)
- Group4 - (value2) *if exists
- Group5 - (value3) *if exists
- Group6 - (value4) *if exists
etc... based on the dynamic values like I explained before.
Question: Whats wrong with my expression I'm using the *
to loop for repeated patterns?
{ "id": ["1", "2"], "name": ["user1", "user2", "user3"], "city": ["Oakland", "San Francisco", "Seattle"], "zip": ["94553", "94523"] }
? – Orthopedicsuser1,user2,etc...
so basically want the each value in it's owncapture-group
– Toby