#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^(?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\-]+))??$)"
Local $sString = "Parse email, also distorted ones, and convert them back to the real ones." & @CRLF & _
"Inspirated by dislick's work: https://regex101.com/r/wB7xJ7/1" & @CRLF & _
"" & @CRLF & _
"frenci98@gmail.com" & @CRLF & _
"st11389@copernico.bo.it" & @CRLF & _
"gigilafontana .at. gmail [dot] com" & @CRLF & _
"d98.copernico@gmail.com" & @CRLF & _
"domenico-tosello at dotcom-sas dot com" & @CRLF & _
"my.e-M4il [at] w3-spAce.org" & @CRLF & _
"email@sub-sub.sub dot domain dot info" & @CRLF & _
"email@foo dot foo dot foo dot foo"
Local $sSubst = "\1@\3.\4"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm