#6576: fix cross-refs in re docs.
This commit is contained in:
parent
982b2fa32d
commit
74f8fc0b1b
|
@ -216,7 +216,7 @@ The special characters are:
|
||||||
flags are described in :ref:`contents-of-module-re`.) This
|
flags are described in :ref:`contents-of-module-re`.) This
|
||||||
is useful if you wish to include the flags as part of the regular
|
is useful if you wish to include the flags as part of the regular
|
||||||
expression, instead of passing a *flag* argument to the
|
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
|
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.
|
used first in the expression string, or after one or more whitespace characters.
|
||||||
|
@ -443,9 +443,9 @@ form.
|
||||||
|
|
||||||
result = re.match(pattern, string)
|
result = re.match(pattern, string)
|
||||||
|
|
||||||
but using :func:`compile` and saving the resulting regular expression object
|
but using :func:`re.compile` and saving the resulting regular expression
|
||||||
for reuse is more efficient when the expression will be used several times
|
object for reuse is more efficient when the expression will be used several
|
||||||
in a single program.
|
times in a single program.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ form.
|
||||||
|
|
||||||
.. note::
|
.. 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.
|
instead.
|
||||||
|
|
||||||
|
|
||||||
|
@ -699,8 +699,8 @@ attributes:
|
||||||
|
|
||||||
.. note::
|
.. 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
|
||||||
instead.
|
:meth:`~RegexObject.search` instead.
|
||||||
|
|
||||||
The optional second parameter *pos* gives an index in the string where the
|
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
|
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.
|
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
|
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])
|
.. method:: RegexObject.split(string[, maxsplit=0])
|
||||||
|
@ -793,10 +793,10 @@ support the following methods and attributes:
|
||||||
.. method:: MatchObject.expand(template)
|
.. method:: MatchObject.expand(template)
|
||||||
|
|
||||||
Return the string obtained by doing backslash substitution on the 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
|
string *template*, as done by the :meth:`~RegexObject.sub` method. Escapes
|
||||||
converted to the appropriate characters, and numeric backreferences (``\1``,
|
such as ``\n`` are converted to the appropriate characters, and numeric
|
||||||
``\2``) and named backreferences (``\g<1>``, ``\g<name>``) are replaced by the
|
backreferences (``\1``, ``\2``) and named backreferences (``\g<1>``,
|
||||||
contents of the corresponding group.
|
``\g<name>``) are replaced by the contents of the corresponding group.
|
||||||
|
|
||||||
|
|
||||||
.. method:: MatchObject.group([group1, ...])
|
.. method:: MatchObject.group([group1, ...])
|
||||||
|
@ -920,16 +920,16 @@ support the following methods and attributes:
|
||||||
|
|
||||||
.. attribute:: MatchObject.pos
|
.. attribute:: MatchObject.pos
|
||||||
|
|
||||||
The value of *pos* which was passed to the :func:`search` or :func:`match`
|
The value of *pos* which was passed to the :meth:`~RegexObject.search` or
|
||||||
method of the :class:`RegexObject`. This is the index into the string at which
|
:meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the
|
||||||
the RE engine started looking for a match.
|
index into the string at which the RE engine started looking for a match.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: MatchObject.endpos
|
.. attribute:: MatchObject.endpos
|
||||||
|
|
||||||
The value of *endpos* which was passed to the :func:`search` or :func:`match`
|
The value of *endpos* which was passed to the :meth:`~RegexObject.search` or
|
||||||
method of the :class:`RegexObject`. This is the index into the string beyond
|
:meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the
|
||||||
which the RE engine will not go.
|
index into the string beyond which the RE engine will not go.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: MatchObject.lastindex
|
.. attribute:: MatchObject.lastindex
|
||||||
|
@ -949,13 +949,15 @@ support the following methods and attributes:
|
||||||
|
|
||||||
.. attribute:: MatchObject.re
|
.. attribute:: MatchObject.re
|
||||||
|
|
||||||
The regular expression object whose :meth:`match` or :meth:`search` method
|
The regular expression object whose :meth:`~RegexObject.match` or
|
||||||
produced this :class:`MatchObject` instance.
|
:meth:`~RegexObject.search` method produced this :class:`MatchObject`
|
||||||
|
instance.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: MatchObject.string
|
.. attribute:: MatchObject.string
|
||||||
|
|
||||||
The string passed to :func:`match` or :func:`search`.
|
The string passed to :meth:`~RegexObject.match` or
|
||||||
|
:meth:`~RegexObject.search`.
|
||||||
|
|
||||||
|
|
||||||
Examples
|
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.
|
>>> displaymatch(pair.match("354aa")) # Pair of aces.
|
||||||
"<Match: '354aa', groups=('a',)>"
|
"<Match: '354aa', groups=('a',)>"
|
||||||
|
|
||||||
To find out what card the pair consists of, one could use the :func:`group`
|
To find out what card the pair consists of, one could use the
|
||||||
method of :class:`MatchObject` in the following manner:
|
:meth:`~MatchObject.group` method of :class:`MatchObject` in the following
|
||||||
|
manner:
|
||||||
|
|
||||||
.. doctest::
|
.. doctest::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue