]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151819: Clarify the conditional-pattern email example in re docs (GH-153072)
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 5 Jul 2026 07:48:02 +0000 (10:48 +0300)
committerGitHub <noreply@github.com>
Sun, 5 Jul 2026 07:48:02 +0000 (07:48 +0000)
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.

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

index 617dc96f479926ca814b866ac52bd46c872cb002..1aefb91e0ceb40505364b99b4b2ad1bba5176d17 100644 (file)
@@ -531,8 +531,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.