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')