# If you'd like to omit non-matching lines from the result; add ';d' to the end of the expression.
sed -E 's/^(?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\-]+))??$)/\1@\3.\4/gm;t' <<< "Parse email, also distorted ones, and convert them back to the real ones.
Inspirated by dislick's work: https://regex101.com/r/wB7xJ7/1
frenci98@gmail.com
st11389@copernico.bo.it
gigilafontana .at. gmail [dot] com
d98.copernico@gmail.com
domenico-tosello at dotcom-sas dot com
my.e-M4il [at] w3-spAce.org
email@sub-sub.sub dot domain dot info
email@foo dot foo dot foo dot foo"
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for SED, please visit: https://www.gnu.org/software/sed/manual/html_node/The-_0022s_0022-Command.html