import re regexObject = re.compile('(\w*)@(\w*).(com|net|org)') matchObject = regexObject.search('python@language.org') if matchObject != None: print "(\w*)@(\w*).(com|net|org): %s (\w*): %s, (\w*): %s, (com|net|org): %s" % (matchObject.group(0), matchObject.group(1), matchObject.group(2), matchObject.group(3))