[Python-checkins] Add re.VERBOSE flag documentation example (GH-97678)

miss-islington webhook-mailer at python.org
Tue Oct 4 21:29:59 EDT 2022


https://github.com/python/cpython/commit/01513758298ae8fb956ce18c01d748d2986cfef3
commit: 01513758298ae8fb956ce18c01d748d2986cfef3
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-10-04T18:29:54-07:00
summary:

Add re.VERBOSE flag documentation example (GH-97678)


The current re.VERBOSE documentation example leaves space for ambiguous
interpretation. One may read that spaces within the `(?:` token are
spaces inside the non-capturing group (such as `(?: )`). This patch
removes the ambiguity by including examples after the statement.
(cherry picked from commit 0ceafa7fa408b64377ea31dd5386152da19ef38a)

Co-authored-by: Athos Ribeiro <athoscribeiro at gmail.com>

files:
M Doc/library/re.rst

diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index 2392785d6c46..3a6e2e7f8908 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -781,7 +781,8 @@ Flags
    more readable by allowing you to visually separate logical sections of the
    pattern and add comments. Whitespace within the pattern is ignored, except
    when in a character class, or when preceded by an unescaped backslash,
-   or within tokens like ``*?``, ``(?:`` or ``(?P<...>``.
+   or within tokens like ``*?``, ``(?:`` or ``(?P<...>``. For example, ``(? :``
+   and ``* ?`` are not allowed.
    When a line contains a ``#`` that is not in a character class and is not
    preceded by an unescaped backslash, all characters from the leftmost such
    ``#`` through the end of the line are ignored.



More information about the Python-checkins mailing list