My Regex voodoo powers were not enough to beat this one up:
Input:
x|a=1|b=2,y|c=3|d=4,
(bonus point if you allow me to drop the last comma)
Desired matches (and groups):
x|a=1|y=2
(x, a, 1, y, 2)
y|c=3|d=4
(y, c, 3, d, 4)
(bonus point if I can name every group)
My failing pattern:
(x|y|z)(?:\|(.+?)=(.+?))*,
Basically, I want x, y or z and ALL the '|' separated pairs of 'this=that' afterwards.
Matches (and groups) I'm getting:
x|a=1|b=2,
(x, b, 2)
y|c=3|d=4,
(y, d, 4)
I have the comma in the matches, but that's no big deal, the main issue is that I'm only getting the last "sub-groups" for each match. Why is the first one ignored?