summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/re.rst49
1 files changed, 26 insertions, 23 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index 7f37db9..2d5e195 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -216,7 +216,7 @@ The special characters are:
flags are described in :ref:`contents-of-module-re`.) This
is useful if you wish to include the flags as part of the regular
expression, instead of passing a *flag* argument to the
- :func:`compile` function.
+ :func:`re.compile` function.
Note that the ``(?x)`` flag changes how the expression is parsed. It should be
used first in the expression string, or after one or more whitespace characters.
@@ -443,9 +443,9 @@ form.
result = re.match(pattern, string)
- but using :func:`compile` and saving the resulting regular expression object
- for reuse is more efficient when the expression will be used several times
- in a single program.
+ but using :func:`re.compile` and saving the resulting regular expression
+ object for reuse is more efficient when the expression will be used several
+ times in a single program.
.. note::
@@ -532,7 +532,7 @@ form.
.. note::
- If you want to locate a match anywhere in *string*, use :meth:`search`
+ If you want to locate a match anywhere in *string*, use :func:`search`
instead.
@@ -699,8 +699,8 @@ attributes:
.. note::
- If you want to locate a match anywhere in *string*, use :meth:`search`
- instead.
+ If you want to locate a match anywhere in *string*, use
+ :meth:`~RegexObject.search` instead.
The optional second parameter *pos* gives an index in the string where the
search is to start; it defaults to ``0``. This is not completely equivalent to
@@ -729,7 +729,7 @@ attributes:
is different from finding a zero-length match at some point in the string.
The optional *pos* and *endpos* parameters have the same meaning as for the
- :meth:`match` method.
+ :meth:`~RegexObject.match` method.
.. method:: RegexObject.split(string[, maxsplit=0])
@@ -793,10 +793,10 @@ support the following methods and attributes:
.. method:: MatchObject.expand(template)
Return the string obtained by doing backslash substitution on the template
- string *template*, as done by the :meth:`sub` method. Escapes such as ``\n`` are
- converted to the appropriate characters, and numeric backreferences (``\1``,
- ``\2``) and named backreferences (``\g<1>``, ``\g<name>``) are replaced by the
- contents of the corresponding group.
+ string *template*, as done by the :meth:`~RegexObject.sub` method. Escapes
+ such as ``\n`` are converted to the appropriate characters, and numeric
+ backreferences (``\1``, ``\2``) and named backreferences (``\g<1>``,
+ ``\g<name>``) are replaced by the contents of the corresponding group.
.. method:: MatchObject.group([group1, ...])
@@ -920,16 +920,16 @@ support the following methods and attributes:
.. attribute:: MatchObject.pos
- The value of *pos* which was passed to the :func:`search` or :func:`match`
- method of the :class:`RegexObject`. This is the index into the string at which
- the RE engine started looking for a match.
+ The value of *pos* which was passed to the :meth:`~RegexObject.search` or
+ :meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the
+ index into the string at which the RE engine started looking for a match.
.. attribute:: MatchObject.endpos
- The value of *endpos* which was passed to the :func:`search` or :func:`match`
- method of the :class:`RegexObject`. This is the index into the string beyond
- which the RE engine will not go.
+ The value of *endpos* which was passed to the :meth:`~RegexObject.search` or
+ :meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the
+ index into the string beyond which the RE engine will not go.
.. attribute:: MatchObject.lastindex
@@ -949,13 +949,15 @@ support the following methods and attributes:
.. attribute:: MatchObject.re
- The regular expression object whose :meth:`match` or :meth:`search` method
- produced this :class:`MatchObject` instance.
+ The regular expression object whose :meth:`~RegexObject.match` or
+ :meth:`~RegexObject.search` method produced this :class:`MatchObject`
+ instance.
.. attribute:: MatchObject.string
- The string passed to :func:`match` or :func:`search`.
+ The string passed to :meth:`~RegexObject.match` or
+ :meth:`~RegexObject.search`.
Examples
@@ -1000,8 +1002,9 @@ To match this with a regular expression, one could use backreferences as such:
>>> displaymatch(pair.match("354aa")) # Pair of aces.
"<Match: '354aa', groups=('a',)>"
-To find out what card the pair consists of, one could use the :func:`group`
-method of :class:`MatchObject` in the following manner:
+To find out what card the pair consists of, one could use the
+:meth:`~MatchObject.group` method of :class:`MatchObject` in the following
+manner:
.. doctest::