Re

<match object>.re

There property gets a reference to the regular expression object from which the match was triggered. It returns a regular expression object.

# from a standard re object

>>> cre = compile(r'(?P<first>t)(?P<last>est) + (o)*')

>>> mo.re.groupindex {'last': 2, 'first': 1}

# Retrieve the re object from the search function.

>>> mo = search(r'(?P<first>t)(?P<last>est)+(o)*',"test") >>> mo.re org.python.modules.Rege [email protected] 0ce6f2

>>> mo.re.groupindex {'last': 2, 'first': 1}

>>> mo.re.pattern '(?P<first>t)(?P<last>est)+(o)*'

Was this article helpful?

0 0

Post a comment