Python 3.15 Soft-Deprecates Confusing re.match Function
Python 3.15 will soft-deprecate the widely used but often misunderstood re.match function, introducing a clearer alias to help developers avoid common regular expression bugs.
Python developers will soon see a shift in how they handle regular expressions, as the upcoming Python 3.15 release introduces a soft deprecation for the long-standing re.match function. Python 3.15 release manager Hugo van Kemenade announced the change, which aims to steer programmers away from a function that has historically caused confusion due to its specific behavior.
In the Python ecosystem, a soft deprecation indicates that an API, as the documentation describes, "should no longer be used to write new code," though there is no active plan or timeline to completely remove it from the language. To replace the legacy function, Python 3.15 introduces re.prefixmatch as a clearer alternative. This new name is designed to be self-explanatory, clearly communicating that the pattern matching is anchored strictly at the beginning of the target string rather than searching the entire text or requiring a full match.
For practitioners, this change addresses a common source of logic errors in Python codebases. Many developers mistakenly assume re.match searches the entire string or matches it fully. Under the new guidance, developers looking to find a pattern anywhere in a string should use re.search, while those needing to validate an entire string against a pattern should opt for re.fullmatch. The introduction of re.prefixmatch provides a precise alternative for the specific use case of checking string prefixes.
While existing code utilizing re.match will continue to function without raising loud deprecation warnings that break production environments, developers are encouraged to adopt the new naming conventions in new projects. This transition will improve code readability and reduce onboarding friction for junior developers who frequently misinterpret the legacy regular expression syntax.
This is our own summary of reporting by Simon Willison



