Philippe Verdy <[email protected]> added the comment:
>>> 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).
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue7132>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com