Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Simple regexp in python working on a string of names and e-mail adresses (See related posts)

Simple regexp in python working on a string of names and e-mail adresses

   1  
   2  #!/usr/bin/env python
   3  
   4  import re
   5  import sys
   6  
   7  mySplit = re.compile (r',', flags=re.MULTILINE)
   8  mailadress = re.compile (r'\<.\D*.\D+@\D+.[.]\D+.\>', flags=re.MULTILINE)
   9  
  10  for i in mySplit.split ("Weng Feng <weng.feng@telia.se>, Erik Andersson <kirean@gmail.com>, Ake Kong <kong@\
  11  goek.se>"):
  12      k = mailadress.search(i.strip())
  13      if k:
  14          print k.group().lstrip("<").rstrip(">")
  15  

You need to create an account or log in to post comments to this site.


Click here to browse all 5545 code snippets

Related Posts