Skip to content

建立 2026-09-15 更新 2026-09-15

Python re 模組

Python 標準函式庫 re 把模式交給引擎執行。日常只要記住六個入口:searchmatchfullmatchfindallfinditersubsplit;同一個模式要用很多次再 compile

import re

沒有匹配時,search / match / fullmatch 回傳 None,不要直接對結果呼叫 .group()

子頁

寫模式時請用 r"..."。行為以官方文件為準;本站範例針對 CPython 3.12+。