1.
#!/usr/bin/python3.5 # import re auth_mail = input('input string:') re_tt = re.compile(r'[\w\W]+\@[a-z]+\.[a-z]+') if re_tt.match(auth_mail): print('%s is email' % (re_tt.match(auth_mail).group())) else: print('not email')
[root@localhost python]# ./regul.py input string:someone@gmail.com someone@gamil.com is email [root@localhost python]# ./regul.py input strint:bill.gates@microsoft.com bill.gates@microsoft.com is email
2. a, b = re.match(r'<([\w\s]+)\s[\w\s]+>\s([\w\W]+)', '<Tom Paris> tom@vosadas.org').groups() print('%s:%s' % (a, b)) Tom:tom@vosadas.org
Sign in to make a reply
迷迷的蛋
1.
2. a, b = re.match(r'<([\w\s]+)\s[\w\s]+>\s([\w\W]+)', '<Tom Paris> tom@vosadas.org').groups() print('%s:%s' % (a, b)) Tom:tom@vosadas.org