My regex looks something like this:
(\d \d)(?:, (\d \d))*
With which I match pairs of numbers, like 1 2, 3 4, 5 6. Capture group 1 would match once here, 1 2, while capture group 2 would match twice, both 3 4 and 5 6, which I both need.
My problem is that
"1 2, 3 4, 5 6".match(/(\d \d)(?:, (\d \d))*/)
returns
["1 2, 3 4, 5 6", "1 2", "5 6"]
Whereas what I really need is something like
["1 2, 3 4, 5 6", "1 2", "3 4", "5 6"]
or
["1 2, 3 4, 5 6", ["1 2"], ["3 4", "5 6"]]
Note: Of course the actual regex and problem are a bit more complicated, just matching \d \d multiple times on the string isn't really feasible for me.
This answer on a similar question for Perl is right in that this would be a good use case for an actual grammar, which I, however, am not going to implement in JavaScript