Soft-deprecating re.match()
- ID
- 23518
- Status
- summarized
- Published
- 11 Sep 2026, 10:47 PM
- Fetched
- 11 Sep 2026, 11:31 PM
- Provider
- Simon Willison
- Category
- developer-ai
- Original URL
- https://simonwillison.net/2026/Sep/11/soft-deprecating-re-match/
- Source URL
- https://simonwillison.net/atom/everything/
Summary
- Score
- 6.0
- Created
- 11 Sep 2026, 11:31 PM
- Tags
- Audience
- developersvibe_coders
What happened
Python 3.15 release manager Hugo van Kemenade has soft-deprecated re.match(), introducing re.prefixmatch() as a clearer replacement that reflects its behavior of anchoring at the start but not the end of a string. The soft deprecation label means no removal is planned, but new code should avoid re.match(). Most use cases are better served by re.search() (match anywhere) or re.fullmatch() (match entire string).
Why it matters
If you write or maintain Python, start using re.prefixmatch(), re.search(), or re.fullmatch() in new code instead of re.match()—the name re.match() has long caused bugs because people assume it does a full match when it only anchors the prefix. No urgent migration is needed for existing code since removal is not promised.
Discussion angle
How many subtle bugs in your own codebase come from re.match() being used when re.fullmatch() or re.search() was intended—and whether a linting rule to flag re.match() in new code is worth adding now.