1
2
3
4
5
6
7
8
9
10
11
12
13
import re
s = input('Email address: ')
# match looks from start string, doesn't require consuming all
# search looks in the middle
match = re.match('([a-zA-Z][a-zA-Z0-9_.]*)@([a-zA-Z0-9][a-zA-Z0-9._]*[a-zA-Z0-9])', s)
if match:
print('Match!')
print(match.groups())
else:
print('Not valid')
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX