How to find out which named regular expression group corresponds to which positional regex group

Mattias Ugelvik uglemat at
Wed Apr 8 15:23:19 CEST 2015

I'm making a string manipulation tool in which I need to know this correlation.

Take this example: re.match('(?P<first>a?)(?P<second>b?)', '')

I need to know that 'first' is group #1, and 'second' is group #2. I
need this to resolve certain ambiguities. I was hopin

More information about the Python-list mailing list