gh-133306: Support \z as a synonym for \Z in regular expressions#133314
Merged
serhiy-storchaka merged 5 commits intopython:mainfrom May 3, 2025
Merged
gh-133306: Support \z as a synonym for \Z in regular expressions#133314serhiy-storchaka merged 5 commits intopython:mainfrom
serhiy-storchaka merged 5 commits intopython:mainfrom
Conversation
sethmlarson
approved these changes
May 2, 2025
Contributor
sethmlarson
left a comment
There was a problem hiding this comment.
LGTM, thanks Serhiy. I only had one thought on this PR:
Lib/re/_parser.py
Outdated
| 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) |
Contributor
There was a problem hiding this comment.
Should we use "deprecated" language here if we're not deprecating \Z?
Member
Author
There was a problem hiding this comment.
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.
hugovk
approved these changes
May 3, 2025
Member
hugovk
left a comment
There was a problem hiding this comment.
Thank you for the PR! Please also run the buildbots before merge.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Member
Author
|
Thank you for review. This feature is not platform-depended, so no need to spend the time and the resources on running the buildbots. |
Pranjal095
pushed a commit
to Pranjal095/cpython
that referenced
this pull request
Jul 12, 2025
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📚 Documentation preview 📚: https://cpython-previews--133314.org.readthedocs.build/