When you have a repeated capture group, (e.g. (a)*
or (a)+
, etc), the capture group will contain only the last match.
So, if I have the regex:
(123\d)+
And the string:
123412351236
You will find that the capture group will contain only 1236
.
I don't know any way around this (besides hard coding the number of subgroups to capture), but you can try capturing the whole group like so:
regex = "(description) (str\\.[\\w\\d]+)((?:,\\s*(?:str\\.[\\w\\d]+))*)"
Which should give you
['description', 'str.bla', ', str.blub, str.yeah, str.no']
Note how the elements are grouped; you have 3 items in the list, the last one being a 'list' within the larger list.