Question:
Write python program to print the user name of a given email address.
Program:
1 2 3 4 5 6 7 8 9 |
import re emailAddress = raw_input("Enter email addresses: ") pat2 = "(\w+)@((\w+\.)+(com))" r2 = re.match(pat2,emailAddress) print r2.group(1) |
Email addresses are in the “[email protected]” format.
Both user names and company names are composed of letters only.
Use \w to match letters.
Output:
1 2 3 |
Enter email addresses: hi@globalsql.com hi |
Leave a Reply