#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?im)^\w+((-|\.|_)\w+)*\w*@\w+(-\w)?(\w*)?\.\w{2,3}(\.\w{2,3})?$"
Local $sString = "# invalid email" & @CRLF & _
"abc" & @CRLF & _
"abc.com" & @CRLF & _
"" & @CRLF & _
"# valid email address" & @CRLF & _
"abc@mail.com" & @CRLF & _
"abc@mail.nz" & @CRLF & _
"abc@mail.co.nz" & @CRLF & _
"abc123@mail.com" & @CRLF & _
"abc.def@music.com" & @CRLF & _
"" & @CRLF & _
"# invalid email prefix" & @CRLF & _
"abc-@mail.com" & @CRLF & _
"abc..def@mail.com" & @CRLF & _
".abc@mail.com" & @CRLF & _
"abc#def@mail.com" & @CRLF & _
"" & @CRLF & _
"# valid email prefix" & @CRLF & _
"abc-d@mail.com" & @CRLF & _
"abc.def@mail.com" & @CRLF & _
"abc@mail.com" & @CRLF & _
"abc_def@mail.com" & @CRLF & _
"" & @CRLF & _
"# invalid domain suffix" & @CRLF & _
"abc.def@mail.c" & @CRLF & _
"abc.def@mail#archive.com" & @CRLF & _
"abc.def@mail" & @CRLF & _
"abc.def@mail..com" & @CRLF & _
"" & @CRLF & _
"# valid domain suffix" & @CRLF & _
"abc.def@mail.cc" & @CRLF & _
"abc.def@mail-archive.com" & @CRLF & _
"abc.def@mail.org" & @CRLF & _
"abc.def@mail.com" & @CRLF & _
"fully-qualified-domain@example.com"
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