This method is only valid when the last call to the match or search method found a match. It returns one or more groups of the match. If no such group exists, the corresponding result is None . If the regular expression was compiled by symcomp instead of compile , the index arguments may also be strings identifying groups by their group name. When the last call to the match or search method found a match, this is a tuple of pairs of indices corresponding to the beginning and end of all parenthesized groups in the pattern.
Indices are relative to the string argument passed to match or search .
The 0-th tuple gives the beginning and end or the whole pattern. When the last match or search failed, this is None . When the last call to the match or search method found a match, this is the string argument passed to that method. When the last match or search failed, this is None . The regular expression pattern as passed to compile or symcomp .