---
id: 20260912-T0-15
title: "Python 3.15将软弃用re.match()，建议不再用于新代码"
title_en: "Python 3.15 to Soft-Deprecate re.match(), Advises Against New Code Use"
url: https://ai.daily.yangsir.net/daily/20260912-T0-15
issue_date: 2026-09-12
publish_date: 2026-09-11T14:47:57.000Z
category: news
source_name: "Simon Willison"
source_url: https://simonwillison.net/2026/Sep/11/soft-deprecating-re-match/
---

# Python 3.15将软弃用re.match()，建议不再用于新代码

Python 3.15计划对re.match()进行软弃用，即标记为"不应再用于编写新代码"，但不承诺未来移除。Python 3.15发布经理Hugo van Kemenade介绍了相关细节。re.match()长期以来因只从字符串开头匹配、容易导致误用而受到批评，社区更推荐使用re.search()配合显式锚点。软弃用意味着现有代码不受影响，但新项目应避免使用。

## English Version

**Python 3.15 to Soft-Deprecate re.match(), Advises Against New Code Use**

Python 3.15 plans to soft-deprecate re.match(), marking it as 'should no longer be used to write new code' without any promise or threat of future removal. Python 3.15 release manager Hugo van Kemenade described the details. re.match() has long been criticized for only matching from the start of a string, making it prone to misuse; the community prefers re.search() with explicit anchors. Soft deprecation means existing code is unaffected, but new projects should avoid it.

---

**来源**：[Simon Willison](https://simonwillison.net/2026/Sep/11/soft-deprecating-re-match/)

**详情页**：https://ai.daily.yangsir.net/daily/20260912-T0-15

---

*智语观潮 · Daily — https://ai.daily.yangsir.net/llms.txt*