The optional second parameter has the same meaning as for the match method. 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 . 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 .