@@ -2559,35 +2559,35 @@ pattern_deepcopy(PatternObject* self, PyObject* memo)
25592559}
25602560
25612561PyDoc_STRVAR (pattern_match_doc ,
2562- "match(string[, pos[, endpos]]) -- > match object or None.\n\
2562+ "match(string[, pos[, endpos]]) -> match object or None.\n \n\
25632563 Matches zero or more characters at the beginning of the string" );
25642564
25652565PyDoc_STRVAR (pattern_search_doc ,
2566- "search(string[, pos[, endpos]]) -- > match object or None.\n\
2566+ "search(string[, pos[, endpos]]) -> match object or None.\n \n\
25672567 Scan through string looking for a match, and return a corresponding\n\
25682568 MatchObject instance. Return None if no position in the string matches." );
25692569
25702570PyDoc_STRVAR (pattern_split_doc ,
2571- "split(string[, maxsplit = 0]) -- > list.\n\
2571+ "split(string[, maxsplit = 0]) -> list.\n \n\
25722572 Split string by the occurrences of pattern." );
25732573
25742574PyDoc_STRVAR (pattern_findall_doc ,
2575- "findall(string[, pos[, endpos]]) -- > list.\n\
2575+ "findall(string[, pos[, endpos]]) -> list.\n \n\
25762576 Return a list of all non-overlapping matches of pattern in string." );
25772577
25782578PyDoc_STRVAR (pattern_finditer_doc ,
2579- "finditer(string[, pos[, endpos]]) -- > iterator.\n\
2579+ "finditer(string[, pos[, endpos]]) -> iterator.\n \n\
25802580 Return an iterator over all non-overlapping matches for the \n\
25812581 RE pattern in string. For each match, the iterator returns a\n\
25822582 match object." );
25832583
25842584PyDoc_STRVAR (pattern_sub_doc ,
2585- "sub(repl, string[, count = 0]) -- > newstring\n\
2585+ "sub(repl, string[, count = 0]) -> newstring.\n \n\
25862586 Return the string obtained by replacing the leftmost non-overlapping\n\
25872587 occurrences of pattern in string by the replacement repl." );
25882588
25892589PyDoc_STRVAR (pattern_subn_doc ,
2590- "subn(repl, string[, count = 0]) -- > (newstring, number of subs)\n\
2590+ "subn(repl, string[, count = 0]) -> (newstring, number of subs)\n \n\
25912591 Return the tuple (new_string, number_of_subs_made) found by replacing\n\
25922592 the leftmost non-overlapping occurrences of pattern with the\n\
25932593 replacement repl." );
@@ -3579,14 +3579,54 @@ match_deepcopy(MatchObject* self, PyObject* memo)
35793579#endif
35803580}
35813581
3582+ PyDoc_STRVAR (match_doc ,
3583+ "The result of re.match() and re.search().\n\
3584+ Match objects always have a boolean value of True." );
3585+
3586+ PyDoc_STRVAR (match_group_doc ,
3587+ "group([group1, ...]) -> str or tuple.\n\n\
3588+ Return subgroup(s) of the match by indices or names.\n\
3589+ For 0 returns the entire match." );
3590+
3591+ PyDoc_STRVAR (match_start_doc ,
3592+ "start([group=0]) -> int.\n\n\
3593+ Return index of the start of the substring matched by group." );
3594+
3595+ PyDoc_STRVAR (match_end_doc ,
3596+ "end([group=0]) -> int.\n\n\
3597+ Return index of the end of the substring matched by group." );
3598+
3599+ PyDoc_STRVAR (match_span_doc ,
3600+ "span([group]) -> tuple.\n\n\
3601+ For MatchObject m, return the 2-tuple (m.start(group), m.end(group))." );
3602+
3603+ PyDoc_STRVAR (match_groups_doc ,
3604+ "groups([default=None]) -> tuple.\n\n\
3605+ Return a tuple containing all the subgroups of the match, from 1.\n\
3606+ The default argument is used for groups\n\
3607+ that did not participate in the match" );
3608+
3609+ PyDoc_STRVAR (match_groupdict_doc ,
3610+ "groupdict([default=None]) -> dict.\n\n\
3611+ Return a dictionary containing all the named subgroups of the match,\n\
3612+ keyed by the subgroup name. The default argument is used for groups\n\
3613+ that did not participate in the match" );
3614+
3615+ PyDoc_STRVAR (match_expand_doc ,
3616+ "expand(template) -> str.\n\n\
3617+ Return the string obtained by doing backslash substitution\n\
3618+ on the string template, as done by the sub() method." );
3619+
35823620static PyMethodDef match_methods [] = {
3583- {"group" , (PyCFunction ) match_group , METH_VARARGS },
3584- {"start" , (PyCFunction ) match_start , METH_VARARGS },
3585- {"end" , (PyCFunction ) match_end , METH_VARARGS },
3586- {"span" , (PyCFunction ) match_span , METH_VARARGS },
3587- {"groups" , (PyCFunction ) match_groups , METH_VARARGS |METH_KEYWORDS },
3588- {"groupdict" , (PyCFunction ) match_groupdict , METH_VARARGS |METH_KEYWORDS },
3589- {"expand" , (PyCFunction ) match_expand , METH_O },
3621+ {"group" , (PyCFunction ) match_group , METH_VARARGS , match_group_doc },
3622+ {"start" , (PyCFunction ) match_start , METH_VARARGS , match_start_doc },
3623+ {"end" , (PyCFunction ) match_end , METH_VARARGS , match_end_doc },
3624+ {"span" , (PyCFunction ) match_span , METH_VARARGS , match_span_doc },
3625+ {"groups" , (PyCFunction ) match_groups , METH_VARARGS |METH_KEYWORDS ,
3626+ match_groups_doc },
3627+ {"groupdict" , (PyCFunction ) match_groupdict , METH_VARARGS |METH_KEYWORDS ,
3628+ match_groupdict_doc },
3629+ {"expand" , (PyCFunction ) match_expand , METH_O , match_expand_doc },
35903630 {"__copy__" , (PyCFunction ) match_copy , METH_NOARGS },
35913631 {"__deepcopy__" , (PyCFunction ) match_deepcopy , METH_O },
35923632 {NULL , NULL }
@@ -3665,7 +3705,7 @@ static PyTypeObject Match_Type = {
36653705 0 , /* tp_setattro */
36663706 0 , /* tp_as_buffer */
36673707 Py_TPFLAGS_DEFAULT , /* tp_flags */
3668- 0 , /* tp_doc */
3708+ match_doc , /* tp_doc */
36693709 0 , /* tp_traverse */
36703710 0 , /* tp_clear */
36713711 0 , /* tp_richcompare */
0 commit comments