]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-151819: Clarify the conditional-pattern email example in re docs (GH-153072...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 5 Jul 2026 08:22:55 +0000 (10:22 +0200)
committerGitHub <noreply@github.com>
Sun, 5 Jul 2026 08:22:55 +0000 (11:22 +0300)
The example pattern does not fail to match '<user@host.com' outright --
re.search finds 'user@host.com' in it; it only fails to match the
whole string.  Reword to say so.
(cherry picked from commit fe9c7213e6576e27ebff6ef039706cd463593310)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Doc/library/re.rst

index 6fbe8993ee223d93f66e6bff91363df862a3b815..456d74292ef4a7eef2f086d488b6d93a270ecae1 100644 (file)
@@ -512,8 +512,9 @@ The special characters are:
    *name* exists, and with ``no-pattern`` if it doesn't. ``no-pattern`` is
    optional and can be omitted. For example,
    ``(<)?(\w+@\w+(?:\.\w+)+)(?(1)>|$)`` is a poor email matching pattern, which
-   will match with ``'<user@host.com>'`` as well as ``'user@host.com'``, but
-   not with ``'<user@host.com'`` nor ``'user@host.com>'``.
+   matches ``'<user@host.com>'`` as well as ``'user@host.com'``, but does not
+   match ``'<user@host.com'`` nor ``'user@host.com>'`` in their entirety
+   (:func:`re.search` finds only ``'user@host.com'`` in the former).
 
    .. versionchanged:: 3.12
       Group *id* can only contain ASCII digits.