This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author LHampton
Recipients LHampton, SilentGhost, docs@python, ezio.melotti, mrabarnett
Date 2020-03-26.04:48:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1585198095.59.0.378560667014.issue40043@roundup.psfhosted.org>
In-reply-to
Content
Matthew Barnett & SilentGhost,
Thank you for your prompt responses. (Really prompt. Amazing!)
SilentGhost,
Regarding your response, I used re.search, not re.match. When I used re.match, the regex failed. When I used re.search, it matched.
Here are my tests.

Your example (cut-and-pasted):
x = re.match(r'(<)?(\w+@\w+(?:\.\w+)+)(?(1)>|$)', '<user@host.com')
print(x)
I received 'None', the expected response.

My example using search:
x = re.search(r'(<)?(\w+@\w+(?:\.\w+)+)(?(1)>|$)', '<user@host.com')
print(x)
I received:
<re.Match object; span=(1, 14), match='user@host.com'>

I understand the re.match failing, since it always starts at the beginning of the string, but why did re.search succeed? After failing with the yes-pattern, when the regex engine backtracked to the (<)? did it decide not to match the '<' at all and skip the character? Seems like it. What do you think?

I am running Python 3.7 via Spyder 4.1.1 on Windows 10.

Respectfully,
Leon
History
Date User Action Args
2020-03-26 04:48:15LHamptonsetrecipients: + LHampton, ezio.melotti, mrabarnett, SilentGhost, docs@python
2020-03-26 04:48:15LHamptonsetmessageid: <1585198095.59.0.378560667014.issue40043@roundup.psfhosted.org>
2020-03-26 04:48:15LHamptonlinkissue40043 messages
2020-03-26 04:48:14LHamptoncreate