4.4. 临时¶
Regex Flag:
class RegexFlag(enum.IntFlag):
A = ASCII = 0x80 # Assume ASCII locale.
B = BESTMATCH = 0x1000 # Best fuzzy match.
D = DEBUG = 0x200 # Print parsed pattern.
E = ENHANCEMATCH = 0x8000 # Attempt to improve the fit after finding the first
# fuzzy match.
F = FULLCASE = 0x4000 # Unicode full case-folding.
I = IGNORECASE = 0x2 # Ignore case.
L = LOCALE = 0x4 # Assume current 8-bit locale.
M = MULTILINE = 0x8 # Make anchors look for newline.
P = POSIX = 0x10000 # POSIX-style matching (leftmost longest).
R = REVERSE = 0x400 # Search backwards.
S = DOTALL = 0x10 # Make dot match newline.
U = UNICODE = 0x20 # Assume Unicode locale.
V0 = VERSION0 = 0x2000 # Old legacy behaviour.
V1 = VERSION1 = 0x100 # New enhanced behaviour.
W = WORD = 0x800 # Default Unicode word breaks.
X = VERBOSE = 0x40 # Ignore whitespace and comments.
T = TEMPLATE = 0x1 # Template (present because re module has it).
# 常用Flag
- re.I:忽略大小写。
- re.L:使用本地化字符集。
- re.M:多行模式,即 ^ 和 $ 匹配每行开头和结尾。
- re.S:点号匹配换行符。
- re.U:使用 Unicode 模式。
- re.X:扩展模式,允许使用空格和注释。
- re.A:ASCII 模式,只匹配 ASCII 字符。