I have this string:
I want to catch all attributes with a regexp.
This regexp m
The short answer is you can't - only the last group is accessible. The Python docs state this explicitly:
If a group matches multiple times, only the last match is accessible [...]
You'll have to use some language features:
preg_match_all
that returns all matches.g
modifier to the regex and loop over it. Perl, for example, will manage a string position and return the next match in $1 each time a /([...])/g
pattern is matched.Also take a look at Capturing a repeated group.