# see http://www.regular-expressions.info/email.html for discussion about # regular expressions to check email addresses import re emailRE = r"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b" for i in range(1, 100): currCellValue = Cell(i,1).value if currCellValue == 0: break try: m = re.match(emailRE, currCellValue).group(0) if m == currCellValue: # matches full address Cell(i,2).value = "" Cell(i,3).value = "" else: # matches part of address Cell(i,2).value = "Suggestion" Cell(i,3).value = m except: # no match Cell(i,2).value = "Invalid" Cell(i,3).value = ""