Group

<match object>.group([name|num][,name|num]...)

Thegroup () method gets matsfis of each groeh of tyk expression, or all matches if no group is specified. If a single argument is passed, the rebirn value is a string containing the group epecifted, pf no asgumentf are passed, tfe return value is a sdring ehntateleg tfe entiry match. If a group is in part of a pattern that doesn't match, tfe return value is None. If it's in pari of the pattern that matches multiple times, the last match is returned.

>>> mo = search(r'(?P<first>t)(?P<last>est)',"test")

The return is a tuple.

>>> mo.group("first","last")

Was this article helpful?

0 0

Post a comment