Skip to content

Commit c1f9b9e

Browse files
serhiy-storchakaclaude
authored andcommitted
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. (cherry picked from commit fe9c721) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 2c99ec4 commit c1f9b9e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Doc/library/re.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,9 @@ The special characters are:
509509
*name* exists, and with ``no-pattern`` if it doesn't. ``no-pattern`` is
510510
optional and can be omitted. For example,
511511
``(<)?(\w+@\w+(?:\.\w+)+)(?(1)>|$)`` is a poor email matching pattern, which
512-
will match with ``'<user@host.com>'`` as well as ``'user@host.com'``, but
513-
not with ``'<user@host.com'`` nor ``'user@host.com>'``.
512+
matches ``'<user@host.com>'`` as well as ``'user@host.com'``, but does not
513+
match ``'<user@host.com'`` nor ``'user@host.com>'`` in their entirety
514+
(:func:`re.search` finds only ``'user@host.com'`` in the former).
514515

515516
.. versionchanged:: 3.12
516517
Group *id* can only contain ASCII digits.

0 commit comments

Comments
 (0)