re模块
. 匹配任意1个字符(除了
)
[ ] 匹配[ ]中列举的字符
d 匹配数字,即0-9
D 匹配非数字,即不是数字
s 匹配空白,即 空格,tab键
S 匹配非空白
w 匹配非特殊字符,即a-z、A-Z、0-9、_、汉字
W 匹配特殊字符,即非字母、非数字、非汉字、非_
重复匹配: . ? * + {m,n} .* .*?
. :代表除了换行符外的任意一个字符
? :代表左边那一个字符重复0次或1次
* :代表左边那一个字符出现0次或无穷次
+ :代表左边那一个字符出现至少一次或无穷次
{m,n} :代表左边那一个字符出现m次到n次
.* :匹配任意长度,任意的字符=====》贪婪匹配
.*? :非贪婪匹配
() :分组
[] :匹配一个指定范围内的字符(这一字符来自于括号内定义的)
| :代表或者