]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add re.VERBOSE flag documentation example (#97678)
authorAthos Ribeiro <athoscribeiro@gmail.com>
Wed, 5 Oct 2022 00:39:42 +0000 (21:39 -0300)
committerGitHub <noreply@github.com>
Wed, 5 Oct 2022 00:39:42 +0000 (17:39 -0700)
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.

Doc/library/re.rst

index 1b9a7b63ef5e1bb2e898f17376c56dd994ebd6b6..5b304f717b07fa38880788378cc0987736672027 100644 (file)
@@ -783,7 +783,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.