#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^([a-z][a-z0-9]{1,13}[_.\-]?[a-z0-9]{1,13})@((([0-9]{1,3})([.]{1})([0-9]{1,3})([.]{1})([0-9]{1,3})([.]{1})([0-9]{1,3}))|([a-z0-9]{1,10}[\-]?[a-z0-9]{1,10}[.]?[a-z0-9-]{1,10}[.]{1}[a-z]{2,4}))$"
Local $sString = "//Valid" & @CRLF & _
"john.doe@mail.com" & @CRLF & _
"johndoe@mail.com" & @CRLF & _
"john-doe@mail.com" & @CRLF & _
"john_doe@mail.com" & @CRLF & _
"john123doe@mail.com" & @CRLF & _
"john123.doe@mail.com" & @CRLF & _
"johndoe456@mail.com" & @CRLF & _
"abc-d@mail.com" & @CRLF & _
"test@test.domain.com" & @CRLF & _
"test@127.1.1.1" & @CRLF & _
"test@test.domain.shop" & @CRLF & _
"" & @CRLF & _
"// Invalid" & @CRLF & _
"abc-@mail.com" & @CRLF & _
"abc..def@mail.com" & @CRLF & _
".abc@mail.com" & @CRLF & _
"abc#def@mail.com" & @CRLF & _
"123abc-d@mail.com" & @CRLF & _
"ABc@mail.com" & @CRLF & _
"test@sub.test.domain.com" & @CRLF & _
"test@test.domain.c"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
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