Created
July 21, 2014 08:40
-
-
Save jimr/8c0521c36add08219c69 to your computer and use it in GitHub Desktop.
Good Enough(TM) email address finder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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