郵箱可以以數字和字母開頭,但是不能以下劃線開頭,以.com結尾,返回郵箱的個數
import re
str1 = '[email protected]@[email protected]'
reg_str1 = r'([a-zA-Z0-9]+[\.\w]*@[\w]+\.com)'
mod = re.compile(reg_str1)
items = re.findall(reg_str1,str1)
for item in items:
print item
print len(items)
output:
[email protected]
[email protected]
[email protected]
3