gh-151819: Clarify the conditional-pattern email example in re docs (GH-153072)

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>
This commit is contained in:
Serhiy Storchaka
2026-07-05 10:48:02 +03:00
committed by GitHub
parent 600e86490f
commit fe9c7213e6
+3 -2
View 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.