@@ -2527,35 +2527,35 @@ pattern_deepcopy(PatternObject* self, PyObject* memo)
25272527}
25282528
25292529PyDoc_STRVAR (pattern_match_doc ,
2530- "match(string[, pos[, endpos]]) -- > match object or None.\n\
2530+ "match(string[, pos[, endpos]]) -> match object or None.\n\
25312531 Matches zero or more characters at the beginning of the string" );
25322532
25332533PyDoc_STRVAR (pattern_search_doc ,
2534- "search(string[, pos[, endpos]]) -- > match object or None.\n\
2534+ "search(string[, pos[, endpos]]) -> match object or None.\n\
25352535 Scan through string looking for a match, and return a corresponding\n\
25362536 MatchObject instance. Return None if no position in the string matches." );
25372537
25382538PyDoc_STRVAR (pattern_split_doc ,
2539- "split(string[, maxsplit = 0]) -- > list.\n\
2539+ "split(string[, maxsplit = 0]) -> list.\n\
25402540 Split string by the occurrences of pattern." );
25412541
25422542PyDoc_STRVAR (pattern_findall_doc ,
2543- "findall(string[, pos[, endpos]]) -- > list.\n\
2543+ "findall(string[, pos[, endpos]]) -> list.\n\
25442544 Return a list of all non-overlapping matches of pattern in string." );
25452545
25462546PyDoc_STRVAR (pattern_finditer_doc ,
2547- "finditer(string[, pos[, endpos]]) -- > iterator.\n\
2547+ "finditer(string[, pos[, endpos]]) -> iterator.\n\
25482548 Return an iterator over all non-overlapping matches for the \n\
25492549 RE pattern in string. For each match, the iterator returns a\n\
25502550 match object." );
25512551
25522552PyDoc_STRVAR (pattern_sub_doc ,
2553- "sub(repl, string[, count = 0]) -- > newstring\n\
2553+ "sub(repl, string[, count = 0]) -> newstring. \n\
25542554 Return the string obtained by replacing the leftmost non-overlapping\n\
25552555 occurrences of pattern in string by the replacement repl." );
25562556
25572557PyDoc_STRVAR (pattern_subn_doc ,
2558- "subn(repl, string[, count = 0]) -- > (newstring, number of subs)\n\
2558+ "subn(repl, string[, count = 0]) -> (newstring, number of subs)\n\
25592559 Return the tuple (new_string, number_of_subs_made) found by replacing\n\
25602560 the leftmost non-overlapping occurrences of pattern with the\n\
25612561 replacement repl." );
@@ -3543,14 +3543,54 @@ match_deepcopy(MatchObject* self, PyObject* memo)
35433543#endif
35443544}
35453545
3546+ PyDoc_STRVAR (match_doc ,
3547+ "The result of re.match() and re.search().\n\
3548+ Match objects always have a boolean value of True." );
3549+
3550+ PyDoc_STRVAR (match_group_doc ,
3551+ "group([group1, ...]) -> str or tuple.\n\
3552+ Return subgroup(s) of the match by indices or names.\n\
3553+ For 0 returns the entire match." );
3554+
3555+ PyDoc_STRVAR (match_start_doc ,
3556+ "start([group=0]) -> int.\n\
3557+ Return index of the start of the substring matched by group." );
3558+
3559+ PyDoc_STRVAR (match_end_doc ,
3560+ "end([group=0]) -> int.\n\
3561+ Return index of the end of the substring matched by group." );
3562+
3563+ PyDoc_STRVAR (match_span_doc ,
3564+ "span([group]) -> tuple.\n\
3565+ For MatchObject m, return the 2-tuple (m.start(group), m.end(group))." );
3566+
3567+ PyDoc_STRVAR (match_groups_doc ,
3568+ "groups([default=None]) -> tuple.\n\
3569+ Return a tuple containing all the subgroups of the match, from 1.\n\
3570+ The default argument is used for groups\n\
3571+ that did not participate in the match" );
3572+
3573+ PyDoc_STRVAR (match_groupdict_doc ,
3574+ "groupdict([default=None]) -> dict.\n\
3575+ Return a dictionary containing all the named subgroups of the match,\n\
3576+ keyed by the subgroup name. The default argument is used for groups\n\
3577+ that did not participate in the match" );
3578+
3579+ PyDoc_STRVAR (match_expand_doc ,
3580+ "expand(template) -> str.\n\
3581+ Return the string obtained by doing backslash substitution\n\
3582+ on the string template, as done by the sub() method." );
3583+
35463584static PyMethodDef match_methods [] = {
3547- {"group" , (PyCFunction ) match_group , METH_VARARGS },
3548- {"start" , (PyCFunction ) match_start , METH_VARARGS },
3549- {"end" , (PyCFunction ) match_end , METH_VARARGS },
3550- {"span" , (PyCFunction ) match_span , METH_VARARGS },
3551- {"groups" , (PyCFunction ) match_groups , METH_VARARGS |METH_KEYWORDS },
3552- {"groupdict" , (PyCFunction ) match_groupdict , METH_VARARGS |METH_KEYWORDS },
3553- {"expand" , (PyCFunction ) match_expand , METH_O },
3585+ {"group" , (PyCFunction ) match_group , METH_VARARGS , match_group_doc },
3586+ {"start" , (PyCFunction ) match_start , METH_VARARGS , match_start_doc },
3587+ {"end" , (PyCFunction ) match_end , METH_VARARGS , match_end_doc },
3588+ {"span" , (PyCFunction ) match_span , METH_VARARGS , match_span_doc },
3589+ {"groups" , (PyCFunction ) match_groups , METH_VARARGS |METH_KEYWORDS ,
3590+ match_groups_doc },
3591+ {"groupdict" , (PyCFunction ) match_groupdict , METH_VARARGS |METH_KEYWORDS ,
3592+ match_groupdict_doc },
3593+ {"expand" , (PyCFunction ) match_expand , METH_O , match_expand_doc },
35543594 {"__copy__" , (PyCFunction ) match_copy , METH_NOARGS },
35553595 {"__deepcopy__" , (PyCFunction ) match_deepcopy , METH_O },
35563596 {NULL , NULL }
@@ -3629,7 +3669,7 @@ static PyTypeObject Match_Type = {
36293669 0 , /* tp_setattro */
36303670 0 , /* tp_as_buffer */
36313671 Py_TPFLAGS_DEFAULT , /* tp_flags */
3632- 0 , /* tp_doc */
3672+ match_doc , /* tp_doc */
36333673 0 , /* tp_traverse */
36343674 0 , /* tp_clear */
36353675 0 , /* tp_richcompare */
0 commit comments