fork download
  1. import re
  2.  
  3. def name_of_email(addr):
  4. return re.match(r'<?([a-zA-Z0-9\s]*)>?',addr).groups()[0]
  5.  
  6. def is_valid_email(addr):
  7. return re.match(r'^(?!\.)[a-zA-Z0-9\.]+@[a-zA-Z0-9]+\.[a-zA-Z]{3,}¥',addr)
  8.  
  9. # 测试:
  10. assert is_valid_email('someone@gmail.com')
  11. assert is_valid_email('bill.gates@microsoft.com')
  12. assert not is_valid_email('bob#example.com')
  13. assert not is_valid_email('mr-bob@example.com')
  14. print('ok')
  15.  
  16. # your code goes here
Success #stdin #stdout 0.18s 15408KB
stdin
Standard input is empty
stdout
ok