FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-133306: Support \z as a synonym for \Z in regular expressions by serhiy-storchaka · Pull Request #133314 · python/cpython · GitHub

/ cpython Public

gh-133306: Support \z as a synonym for \Z in regular expressions - #133314

Merged
serhiy-storchaka merged 5 commits into
python:mainfrom
serhiy-storchaka:re-z
May 3, 2025
Merged

gh-133306: Support \z as a synonym for \Z in regular expressions#133314
serhiy-storchaka merged 5 commits into
python:mainfrom
serhiy-storchaka:re-z

Conversation

serhiy-storchaka commented May 2, 2025
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

sethmlarson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, thanks Serhiy. I only had one thought on this PR:

Comment thread 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should we use "deprecated" language here if we're not deprecating \Z?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you for the PR! Please also run the buildbots before merge.

Comment thread Doc/whatsnew/3.14.rst Outdated
Comment thread Doc/library/re.rst Outdated
serhiy-storchaka and others added 2 commits May 3, 2025 10:10
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>

Copy link
Copy Markdown
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.

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

serhiy-storchaka enabled auto-merge (squash) May 3, 2025 07:30
serhiy-storchaka merged commit ac56f8c into python:main May 3, 2025
serhiy-storchaka deleted the re-z branch May 3, 2025 09:41
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL