I want to capture repeated groups in Python as a separate list:
match = re.match(r'!((?:abc|123)+)!', '!abc123abc!').groups()
print(match)
print(len(match))
This gives back a tuple with a single element:
('abc123abc',)
1
How can I get the following output?
('abc', '123', 'abc',)
3
Following this helpful article on capturing repeated groups I now understand the earlier problem I had, trying to repeat a capturing group instead of capturing a repeated group. But still I don't understand how or if it is possible to capture different groups for better post-processing.
Please note that I cannot do without the pre-/suffix, because this also contains multiple capturing groups. My actual use case differs a little bit from this MWE, but should be clear enough.