# Python re.match 参考

URL: https://caijiao.org/reference/python/re-match
Source: docs/reference/python/re-match.md
Description: Python re.match 参考，整理标准库调用语法、参数、示例、返回值和常见错误。

Python re.match 参考，整理标准库调用语法、参数、示例、返回值和常见错误。

## 语法

```python
import re

match = re.match(pattern, text)
```

## 参数

- `pattern`：正则表达式模式。
- `string / flags`：待匹配文本和匹配标志。

## 返回值

返回 Match 对象、字符串列表、拆分结果或替换后的文本。

## 示例

```python
import re

print(re.match(r"id", "id=12"))
```

## 常见错误

- 贪婪匹配可能吞掉过多内容。
- match 只从开头匹配，全文查找应使用 search 或 findall。

## 相关内容

- [Python 教程](/python/)
- [Python 问题库](/how-to/python/)
- [JSON Formatter](/tool/json-formatter)
- [Timestamp Converter](/tool/timestamp-converter)
