# Python re.flags 参考

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

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

## 语法

```python
import re

pattern = re.compile(r"abc", flags=re.I)
```

## 参数

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

## 返回值

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

## 示例

```python
import re

print(re.search(r"abc", "ABC", flags=re.I))
```

## 常见错误

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

## 相关内容

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