Message94053
ezio said:
>>> re.match('^(\d{1,3})(?:\.(\d{1,3})){3}$', '192.168.0.1').groups()
('192', '1')
> If I understood correctly what you are proposing, you would like it to
return (['192'], ['168', '0', '1']) instead.
Yes, exactly ! That's the correct answer that should be returned, when
the R flag is set.
> This will also require an additional step to join the two lists to get
the list with the 4 values.
Yes, but this is necessary for full consistency of the group indexes.
The current return value is clearly inconsistant (generally it returns
the last occurence of the capturing group, but I've discovered that this
is not always the case, because of matches that are returned after
backtracking...)
It is then assumed that when the R flag is set, ALL occurences of
repeated groups will be returned individually, instead of just a
'random' one. Note that for full generalization of the concept, there
should even be lists of lists if a capturing group contains itself
another inner capturing group (with its own index), in order to
associate them correctly with each occurence of the outer capturing
group (however I've still not experimented this in my local
experimentation, so all occurences are grouped in the same returned
list, independantly of the occurence of the outer capturing group in
which they were found). |
|
Date |
User |
Action |
Args |
2009-10-14 23:44:02 | verdy_p | set | recipients:
+ verdy_p, ezio.melotti, r.david.murray |
2009-10-14 23:44:02 | verdy_p | set | messageid: <1255563842.89.0.44976557928.issue7132@psf.upfronthosting.co.za> |
2009-10-14 23:44:01 | verdy_p | link | issue7132 messages |
2009-10-14 23:44:01 | verdy_p | create | |
|