Get named groups from a regular expression
Peter Otten
__peter__ at web.de
Tue Jul 1 11:29:17 EDT 2014
Florian Lindner wrote:
> Is there a way I can extract the named groups from a regular expression?
> e.g. given "(?P<testgrp>\d)" I want to get something like ["testgrp"].
Easy, just write a regular expression to parse regular expressions ;)
(Sorry, I can't contribute something constructive, my first idea, re.DEBUG
doesn't help)
> OR
>
> Can I make the match object to return default values for named groups,
> even if no match was produced?
More information about the Python-list
mailing list