譯自官方API,備查待補充稽物。
- re.compile(pattern, flags=0)
將正則表達式patten編譯成正則表達式對象巢价。 - re.DEBUG
顯示關(guān)于正則表達式的debug信息倒得。 - re.I
re.IGNORECASE
執(zhí)行大小寫不敏感匹配农渊。這并不被當前的語言環(huán)境影響患蹂。 - re.L
re.LOCALE
使\w
,\W
,\b
,\B
,\s
和\S
取決于當前語言環(huán)境。 - re.M
re.MULTILINE
指定匹配字符^
和$
的模式砸紊。具體見文檔传于。 - re.S
re.DOTALL
指定匹配字符的模式。
-re.U
re.UNICODE
指定匹配字符的模式醉顽。 - re.X
re.VERBOSE
可在正則表達式中間添加注釋使正則更易讀沼溜。 - re.search(pattern, string, flags=0)
查找并返回MatchObject
實例。 - re.split(pattern, string, maxsplit=0, flags=0)
根據(jù)pattern
的出現(xiàn)切分string
徽鼎。 - re.findall(pattern, string, flags=0)
返回匹配的字符串列表盛末。 - re.finditer(pattern, string, flags=0)
返回匹配的iterator弹惦。 - re.sub(pattern, repl, string, count=0, flags=0)
從string
中用repl
替換pattern
并返回否淤。 - re.subn(pattern, repl, string, count=0, flags=0)
功能和re.sub
一樣,但返回的是一個元組(new_string, number_of_subs_made)
棠隐。 - re.escape(string)
返回所有帶著非字母數(shù)字反斜杠的字符串石抡。這在當你想匹配的string中含有正則表達式時很有用。 - re.purge()
Clear the regular expression cache.