Skip to content

gh-86519: Update docs for prefixmatch - #148096

Merged
hugovk merged 12 commits into
python:mainfrom
hugovk:3.15-howto-regex-re.match
Apr 14, 2026
Merged

gh-86519: Update docs for prefixmatch#148096
hugovk merged 12 commits into
python:mainfrom
hugovk:3.15-howto-regex-re.match

Conversation

@hugovk

@hugovkhugovk commented Apr 4, 2026

Copy link
Copy Markdown
Member

regex HOWTO:

Update match to prefixmatch.

And many of these examples don't specifically need to match a prefix, so let's prefer search for general cases, and introduce it first.

Other files:

Change to prefixmatch where prefixing is important and relevant, otherwise change to search.


📚 Documentation preview 📚: https://cpython-previews--148096.org.readthedocs.build/

@bedevere-appbedevere-appBot added awaiting core review docs Documentation in the Doc dir skip news labels Apr 4, 2026
@hugovkhugovk changed the title Update regex HOWTO for prefixmatchgh-86519: Update regex HOWTO for prefixmatchApr 4, 2026
@hugovk
hugovk marked this pull request as draft April 4, 2026 15:38
@hugovkhugovk changed the title gh-86519: Update regex HOWTO for prefixmatchgh-86519: Update docs for prefixmatchApr 4, 2026
@hugovk
hugovk marked this pull request as ready for review April 4, 2026 16:06
Comment threadDoc/howto/regex.rst Outdated
(2, 7)

Sometimes you'll be tempted to keep using :func:`re.match`, and just add ``.*``
Sometimes you'll be tempted to keep using :func:`re.prefixmatch`, and just add ``.*``

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.

is this temptation true any longer?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Hopefully the new name makes things clearer. I've removed this bit.

Comment threadDoc/howto/regex.rst Outdated
Comment threadDoc/howto/regex.rst Outdated
| | location where this RE matches. |
+------------------+-----------------------------------------------+
| ``prefixmatch()``| Determine if the RE matches at the beginning |
| | of the string. |

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.

I'd at least leave a little mention of "Previously named match()" with a link to the canonical doc section explaining the renaming and soft deprecation in here.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Added.

Comment threadDoc/howto/regex.rst Outdated
@AlexWaygood
AlexWaygood removed their request for review April 6, 2026 21:41
@hugovk

Copy link
Copy Markdown
MemberAuthor

Any further review comments?

Comment threadDoc/howto/regex.rst Outdated
@hugovk
hugovk merged commit bdb0b36 into python:mainApr 14, 2026
34 checks passed
@github-project-automationgithub-project-automationBot moved this from Todo to Done in Docs PRsApr 14, 2026
@hugovk
hugovk deleted the 3.15-howto-regex-re.match branch April 14, 2026 17:15
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docsDocumentation in the Doc dirskip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@hugovk@gpshead@JelleZijlstra@hauntsaninja