Author verdy_p
Recipients ezio.melotti, verdy_p
Date 2009-10-15.00:45:28
SpamBayes Score 1.69204e-06
Marked as misclassified No
Message-id <1255567530.46.0.269372546886.issue7132@psf.upfronthosting.co.za>
In-reply-to
Content
>>> 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).
History
Date User Action Args
2009-10-15 00:45:30verdy_psetrecipients: + verdy_p, ezio.melotti
2009-10-15 00:45:30verdy_psetmessageid: <1255567530.46.0.269372546886.issue7132@psf.upfronthosting.co.za>
2009-10-15 00:45:29verdy_plinkissue7132 messages
2009-10-15 00:45:28verdy_pcreate