首先来个简单的例子,利用Python实现匹配163邮箱的代码:
 
 
- __author__ = ‘杨鑫‘  
- import re  
- text = input("Please input your Email address:\n"):  
- if re.match(r‘[0-9a-zA-Z_]{0,19}@163.com‘,text):  
-     print(‘Email address is Right!‘)  
- else:  
-     print(‘Please reset your right Email address!‘)  
 

 
 
接着来一个匹配所有邮箱格式的代码:
 
- __author__ = ‘杨鑫‘  
- import re  
- text = input("Please input your Email address:\n")  
- if re.match(r‘^[0-9a-zA-Z_]{0,19}@[0-9a-zA-Z]{1,13}\.[com,cn,net]{1,3}$‘,text):  
-     print(‘Email address is Right!‘)  
- else:  
-     print(‘Please reset your right Email address!‘)  
 

Python实现正则表达式匹配任意的邮箱
原文:http://www.cnblogs.com/to-creat/p/7582441.html