import re
email_pattern =r'[0-9]{5,10}@([\w\.-]+)(\.[\w\.]+)'
emails = re.search(email_pattern, "这里有一个邮件528845465@qq.com", flags=0)
print(emails.group())
cellphone_pattern = r'[0-9]{11}'
phoneNumbers = re.findall(cellphone_pattern, '这里是18771199775和17651144464', flags=0)
print(phoneNumbers)
IDCards_pattern = r'[0-9]{18}'
IDs = re.findall(IDCards_pattern, '这里是420821199112211221和420821199911112223', flags=0)
print(IDs)
相应输出结果:
528845465@qq.com
['18771199775', '17651144464']
['420821199112211221', '420821199911112223']
对于邮箱地址抽取而言,现实情况下需要更复杂的正则表达式才能完全验证电子邮件地址,这里只是简单演示