Skip to content

Instantly share code, notes, and snippets.

@jimr
Created July 21, 2014 08:40
Show Gist options
  • Save jimr/8c0521c36add08219c69 to your computer and use it in GitHub Desktop.
Save jimr/8c0521c36add08219c69 to your computer and use it in GitHub Desktop.
Good Enough(TM) email address finder
import re
pattern = re.compile(
r'(mailto:)?(?P<email>[^(\s|<|\[))]*@[^\s]*\.[^(\s|>|;|,|\])]*)'
)
test_data = '''
This is [email protected] string with some Email Addresses
<[email protected]> in it. There are also
some mailto:[email protected] addresses in here too.
'''
for match in pattern.finditer(test_data):
print match.groupdict().get('email')
# would print:
# [email protected]
# [email protected]
# [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment