正则匹配手机号和网址

import re
#常见实例
#1.匹配.com或.cn后缀的url网址
#[^\s]代表匹配非空字符
# parrent="[a-zA-Z]+://[^\s]*[.com|.cn]"
# string="<a href='http://www.baidu.com'>百度首页</a>"
# string1="www.baidu54.cn"
# result=re.search(parrent,string)
# result1=re.search(parrent,string1)
# print(result)
# print(result1)
#匹配手机号码
parrent1='1[3|4|5|6|7|8]\d{9}'
string2='weyeugwegui17589744484'
string3='ewgqhjds456785213223748854dwasd'
result2=re.search(parrent1,string2)
result3=re.search(parrent1,string3)
print(result2)
print(result3)

猜你喜欢

转载自blog.csdn.net/weixin_42341608/article/details/80902223