Created
November 29, 2011 22:36
-
-
Save joshz/1406917 to your computer and use it in GitHub Desktop.
extract first number from an email
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 email | |
import re | |
e = ''' | |
some string with full email contents | |
''' | |
msg = email.message_from_string(e) | |
body = msg.get_payload() | |
n = re.search(r'\d+', body, re.MULTILINE) | |
print n.group() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment