I don't understand this regex.groups() behaviour
fredrik at pythonware.com
Fri Jun 20 11:31:44 CEST 2003
Grzegorz Adam Hankiewicz wrote:
> This last result is correct, because the given string doesn't
> match the regular expression. However, looks like either by bug or
> limitation of the re engine, it's impossible to retrieve repeated
> groups in a regular expression.
It's not a bug, it's the way groups work. I've told you this, Michael's
told you this, Harvey's told you this, it works the same way in most
(all?) languages, it's documented in lots of places, and if you think
about it, you can probably figure out *why* groups work this way.
So why don't you just fix your code, and get over it?
(If you cannot think of any other way to solve your problem, put the
group brackets *outside* the repeated sequence, and use "findall" to
split the resulting string)
More information about the Python-list