# Python re.groups 参考

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

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

## 语法

```python
import re

values = match.groups()
```

## 参数

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

## 返回值

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

## 示例

```python
import re

match = re.search(r"(\w+)=(\d+)", "id=12")
print(match.groups())
```

## 常见错误

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

## 相关内容

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