python 正则
正则
常用方法
1.findall()
返回结果为列表
''' 内容提取 ''' data='window.QRLogin.code = 200; window.QRLogin.uuid = "gbGEZLvmhQ==";' import re ret=re.findall('uuid = "(.*)"',data) print(ret) ''' 结果 ['gbGEZLvmhQ=='] '''
2.search()
3.match
方法试图从字符串的起始部分对模式进行匹配。
4.group
用于选择匹配
5.groups
6.compile
""" Python re校验手机号 """ import re r = re.compile(r'^1[3-9][0-9]{9}$') print(r.match("12211111111")) print(r.match("13211111111")) print(r.match("1a211111111"))
用于提取