正则表达式匹配手机号、QQ号、邮箱

import  re
#匹配邮箱
# def email_match(str1):
#     #[email protected]
#     res = re.findall(r"(\w{1,}@\w{1,}.(com|cn|com.cn)$)",(str1))
#     print(res)
# # email_match("[email protected]")
# #匹配QQ号
# def qq_match(str1):
#     res = re.match(r"^[1-9]\d{3,9}$",str1)
#     print(res)
# # qq_match("91231212")
# #匹配手机号
# def phoneNum_match(str1):
#     # 移动的号段:134(0 - 8)、135、136、137、138、139、147(预计用于TD上网卡)、150、151、152、157(TD专用)、158、159、187(未启用)、188(TD专用)
#     # 联通的号段:130、131、132、155、156(世界风专用)、185(未启用)、186(3g)
#     # 电信的号段:133、153、180(未启用)、189
#     res = re.match(r"(13\d{9}$)|(15[0-35-9]\d{8}$)|(147\d{8}$)|(18[05-9]\d{8}$)",str1)
#     print(res)
# # phoneNum_match("18911111111")

猜你喜欢

转载自blog.csdn.net/luslin/article/details/81704003