Skip to content

[3.11] Fix Sphinx warnings in re module docs (GH-107044). #107055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Doc/library/re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ The special characters are:
(``b'\x00'``-``b'\x7f'``) in :class:`bytes` replacement strings.


.. _re-special-sequences:

The special sequences consist of ``'\'`` and a character from the list below.
If the ordinary character is not an ASCII digit or an ASCII letter, then the
resulting RE will match the second character. For example, ``\$`` matches the
Expand Down Expand Up @@ -778,6 +780,17 @@ Flags
Corresponds to the inline flag ``(?s)``.


.. data:: U
UNICODE

In Python 2, this flag made :ref:`special sequences <re-special-sequences>`
include Unicode characters in matches. Since Python 3, Unicode characters
are matched by default.

See :const:`A` for restricting matching on ASCII characters instead.

This flag is only kept for backward compatibility.

.. data:: X
VERBOSE

Expand Down Expand Up @@ -1518,14 +1531,14 @@ Simulating scanf()

.. index:: single: scanf()

Python does not currently have an equivalent to :c:func:`scanf`. Regular
Python does not currently have an equivalent to :c:func:`!scanf`. Regular
expressions are generally more powerful, though also more verbose, than
:c:func:`scanf` format strings. The table below offers some more-or-less
equivalent mappings between :c:func:`scanf` format tokens and regular
:c:func:`!scanf` format strings. The table below offers some more-or-less
equivalent mappings between :c:func:`!scanf` format tokens and regular
expressions.

+--------------------------------+---------------------------------------------+
| :c:func:`scanf` Token | Regular Expression |
| :c:func:`!scanf` Token | Regular Expression |
+================================+=============================================+
| ``%c`` | ``.`` |
+--------------------------------+---------------------------------------------+
Expand All @@ -1550,7 +1563,7 @@ To extract the filename and numbers from a string like ::

/usr/sbin/sendmail - 0 errors, 4 warnings

you would use a :c:func:`scanf` format like ::
you would use a :c:func:`!scanf` format like ::

%s - %d errors, %d warnings

Expand Down