介绍
正则表达式也叫做匹配模式(Pattern),它由一组具有特定含义的字符串组成,通常用于匹配和替换文本。
正则表达式(英语:Regular Expression、regex 或 regexp,缩写为 RE),也译为正规表示法、常规表示法,在计算机科学中,是指一个用来描述或者匹配一系列符合某个句 法规则的字符串的单个字符串。
re模块
相关方法
>>> dir(re)
['A', 'ASCII', 'DEBUG', 'DOTALL', 'I', 'IGNORECASE', 'L', 'LOCALE',
'M', 'MULTILINE', 'Match', 'Pattern', 'RegexFlag', 'S', 'Scanner',
'T', 'TEMPLATE', 'U', 'UNICODE', 'VERBOSE', 'X', '_MAXCACHE',
'__all__', '__builtins__', '__cached__', '__doc__', '__file__',
'__loader__', '__name__', '__package__', '__spec__',
'__version__', '_cache', '_compile', '_compile_repl', '_expand',
'_locale', '_pickle', '_special_chars_map', '_subx', 'compile',
'copyreg', 'enum', 'error', 'escape'