On Tuesday, 1 July 2014 16:12:34 UTC+1, Florian Lindner wrote: > Hello, > > > > 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"]. > > > > OR > > > > Can I make the match object to return default values for named groups, even > > if no match was produced? > > > > Thanks, > > Florian
If you can, my approach would to have a class which you use both to create the regex (using group names), and return the names of the groups in the regex you have created. As I say, this might not be possible in your case though. Jon N -- https://mail.python.org/mailman/listinfo/python-list