正则表达式匹配邮箱
(?:xxx)为非捕获分组
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。# -*- coding:utf-8 -* import re str1 = 'fdg.lll.pp123@163.com hdfh.abc@qq.com hidfsd@qq.com.com gfgfa@qq.com bdfdg@163.com' reg_str1 = r'(?:[0-9a-zA-Z_]+.)+@[0-9a-zA-Z]{1,13}\.[com,cn,net]{1,3}'#正则匹配出邮箱 mod = re.compile(reg_str1) items = mod.findall(str1) print(items)
输出结果:
['fdg.lll.pp123@163.com', 'hdfh.abc@qq.com', 'hidfsd@qq.com.com gfgfa@qq.com', 'bdfdg@163.com']

更多精彩