Regular Expressions 101

Community Patterns

Email parser, also distorted forms

0

Regular Expression
Python

r"
^(?P<Username>[-\w\.]+)(?:\s+\W*at\W*\s+|\s*[^\@\s]*?@[^\@\s]*?\s*)(?P<Domain>([\w\-]+)(?:(?:\.|\s+\W*?dot\W*?\s+)([\w\-]+))+?(?:(?:\.|\s+\W*?dot\W*?\s+)([\w\-]+))??$)
"
gm

Description

Parses email, also distorted ones, and convert them back to the real ones. It can recognize at maximum two dots notations, just add '.\5' at the end of the substitution string. Inspirated by dislick's work: https://regex101.com/r/wB7xJ7/1

Submitted by fine_dust - 9 years ago