Skip to content

Instantly share code, notes, and snippets.

@joshz
Created November 29, 2011 22:36
Show Gist options
  • Save joshz/1406917 to your computer and use it in GitHub Desktop.
Save joshz/1406917 to your computer and use it in GitHub Desktop.
extract first number from an email
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