fork download
  1. import re
  2.  
  3. email = "abc at xyz.com, abc At xyz.com, abc (at) xyz [dot] com"
  4. pa = re.compile(r'\W*(at|dot)\W*', flags=re.IGNORECASE)
  5. em = pa.sub(lambda m: {'dot': '.', 'at': '@'}[m.group(1).lower()], email)
  6. print(em)
Success #stdin #stdout 0.01s 7024KB
stdin
Standard input is empty
stdout
abc@xyz.com, abc@xyz.com, abc@xyz.com