Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abd4a05

Browse files
committed
Fix issue11283 - Clarifying a re pattern in the re module docs for conditional regex
1 parent 26606fd commit abd4a05

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

Doc/library/re.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,12 @@ The special characters are:
295295
match at the beginning of the string being searched.
296296

297297
``(?(id/name)yes-pattern|no-pattern)``
298-
Will try to match with ``yes-pattern`` if the group with given *id* or *name*
299-
exists, and with ``no-pattern`` if it doesn't. ``no-pattern`` is optional and
300-
can be omitted. For example, ``(<)?(\w+@\w+(?:\.\w+)+)(?(1)>)`` is a poor email
301-
matching pattern, which will match with ``'<[email protected]>'`` as well as
302-
``'[email protected]'``, but not with ``'<[email protected]'``.
298+
Will try to match with ``yes-pattern`` if the group with given *id* or
299+
*name* exists, and with ``no-pattern`` if it doesn't. ``no-pattern`` is
300+
optional and can be omitted. For example,
301+
``(<)?(\w+@\w+(?:\.\w+)+)(?(1)>|$)`` is a poor email matching pattern, which
302+
will match with ``'<[email protected]>'`` as well as ``'[email protected]'``, but
303+
not with ``'<[email protected]'`` nor ``'[email protected]>'`` .
303304

304305

305306
The special sequences consist of ``'\'`` and a character from the list below.

0 commit comments

Comments
 (0)