---
title: "Python: use re.prefixmatch() instead of re.match() from Python 3.15"
url: https://daily.dev/posts/python-use-re-prefixmatch-instead-of-re-match-from-python-3-15-btkfohpmx
source_url: https://adamj.eu/tech/2026/08/16/python-prefer-prefixmatch-to-match
type: article
source: "Adam Johnson"
published: 2026-08-15T23:11:12.312Z
updated: 2026-08-15T23:11:35.455Z
tags: ["python"]
reading_time: 3
upvotes: 6
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Python: use re.prefixmatch() instead of re.match() from Python 3.15

**[Adam Johnson](https://daily.dev/sources/adamj)** · 3 min read · 6 upvotes · 0 comments

## Summary

Python's re.match() only anchors matching at the start of a string, not the end, which can cause subtle validation bugs like accepting garbage suffixes after a valid prefix. Python 3.15, expected October 2026, introduces re.prefixmatch() and re.Pattern.prefixmatch() as exact synonyms for match() with a clearer name that signals prefix-only matching. The re.match() name is now soft deprecated in favor of prefixmatch(), though it still works without warnings and there are no plans to remove it. Developers who need to validate an entire string should still use fullmatch() rather than either match() or prefixmatch().

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://adamj.eu/tech/2026/08/16/python-prefer-prefixmatch-to-match>

## Questions this post answers

### What is the difference between re.match() and re.fullmatch() in Python and why does it matter for validation?

re.match() only anchors at the start of the string, so a pattern like \d{6} matches '345071-in-abbey-wood' because it finds six digits at the beginning, ignoring the garbage suffix. re.fullmatch() requires the entire string to conform to the pattern, correctly rejecting that same input. For validation functions, fullmatch() is the correct choice, not match().

_Track regex gotchas like this one on daily.dev so validation bugs don't slip into production._

### What does re.prefixmatch() do in Python 3.15 and how is it different from re.match()?

re.prefixmatch() and re.Pattern.prefixmatch(), added in Python 3.15 (expected October 2026), are exact synonyms for re.match() and re.Pattern.match() respectively, with identical behavior including still matching only a prefix rather than the whole string. The new name simply makes the prefix-only semantics explicit at the call site, since match() in Python confusingly does not mean 'match anywhere' as it does in JavaScript, PCRE, or Ruby.

_Follow how Python's regex API evolves on daily.dev when planning upgrades to newer versions._

### Is Python's re.match() function deprecated in Python 3.15?

re.match() is soft deprecated as of Python 3.15 in favor of re.prefixmatch(), meaning it still works with no warnings and there are currently no plans to add a warning or remove it. The soft deprecation exists purely to encourage using the more descriptive prefixmatch() name going forward once code supports Python 3.15 or later.

_Keep tabs on soft deprecations like this on daily.dev before they become breaking changes._

## Similar posts on daily.dev

- [Regular Expressions: Regexes in Python \(Part 1\) Quiz – Real Python](https://daily.dev/posts/regular-expressions-regexes-in-python-part-1-quiz-real-python-fxaebeli8) · Real Python · 0 upvotes · 0 comments
- [Use “\\A...\\z”, not “^...$” with Python regular expressions](https://daily.dev/posts/use-a-z-not-with-python-regular-expressions-htt0oyms0) · Lobsters · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python)

[View this post on daily.dev](https://daily.dev/posts/python-use-re-prefixmatch-instead-of-re-match-from-python-3-15-btkfohpmx)
