Reading Time: 1 minutesExtract information from an email address in Python
Extract information from an email address in Python
Write a Python program to extract information from an email address. Given that you are provided an email address in the format firstname.lastname@organization.com and there are no numbers in the email address, write a Python program to extract the first name, last name and organization name from it.
sampleEmail = 'ethan.hunt@imf.com' |
matchedObject = re.search( '(\w+)\.(\w+)@(\w+)\.com' , sampleEmail) |
print ( matchedObject.groups() ) |
To learn more about Regular Expressions in Python, click here.
See also: