Message94065
>>> 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.
In fact it can be assembled in a single array directly in the regexp, by
naming the destination capturing group (with the same name, it would get
the same group index, instead of of allocating a new one). E.g., with
someting like:
>>> re.match('^(?P<parts>=\d{1,3})(?:\.(?P<parts>=\d{1,3})){3}$',
'192.168.0.1').groups()
would return ("parts": ['192', '168', '0', '1']) in the same first
group.
This could be used as well in PHP (which supports associative arrays for
named groups which are also indexed positionnaly). |
|
Date |
User |
Action |
Args |
2009-10-15 00:45:30 | verdy_p | set | recipients:
+ verdy_p, ezio.melotti |
2009-10-15 00:45:30 | verdy_p | set | messageid: <1255567530.46.0.269372546886.issue7132@psf.upfronthosting.co.za> |
2009-10-15 00:45:29 | verdy_p | link | issue7132 messages |
2009-10-15 00:45:28 | verdy_p | create | |
|