-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-133306: Support \z as a synonym for \Z in regular expressions #133314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks Serhiy. I only had one thought on this PR:
Lib/re/_parser.py
Outdated
@@ -49,7 +49,8 @@ | |||
r"\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), | |||
r"\w": (IN, [(CATEGORY, CATEGORY_WORD)]), | |||
r"\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), | |||
r"\Z": (AT, AT_END_STRING), # end of string | |||
r"\z": (AT, AT_END_STRING), # end of string | |||
r"\Z": (AT, AT_END_STRING), # end of string (deprecated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use "deprecated" language here if we're not deprecating \Z
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What words do you suggest? "legacy"? "obsolete"?
Due to its subtle difference from other common implementations, it is very likely that \Z
will be deprecated and removed in future, when it will be safe. It is kept for compatibility with older Python versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! Please also run the buildbots before merge.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Thank you for review. This feature is not platform-depended, so no need to spend the time and the resources on running the buildbots. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
pythonGH-133314) \Z was an error inherited from PCRE 0.95. It was fixed in PCRE 2.0. In other engines, \Z means not “anchor at string end”, but “anchor before optional newline at string end”. \z means “anchor at string end” in most RE engines.
📚 Documentation preview 📚: https://cpython-previews--133314.org.readthedocs.build/