#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?imx)(?P<group_definition>" & @CRLF & _
" \(" & @CRLF & _
" (?P<options>[^\:\>\s\(\)]*[\:\>])?" & @CRLF & _
" (?P<pattern>" & @CRLF & _
" (?:[^\)\(]*(?R)*)*" & @CRLF & _
" )" & @CRLF & _
" \)" & @CRLF & _
" (?P<quantifier>" & @CRLF & _
" (?:[\*\+\?])|" & @CRLF & _
" (?:" & @CRLF & _
" \{(?P<min>\d*)" & @CRLF & _
" (?:" & @CRLF & _
" ," & @CRLF & _
" (?P<max>\d*)?" & @CRLF & _
" )?" & @CRLF & _
" \}" & @CRLF & _
" )" & @CRLF & _
" )?" & @CRLF & _
")"
Local $sString = "^(?P<line>(?P<junk>(?!(?:Message\-ID:)\s(?:\<)|(?:<)|(?:\s))(?!(?:From:)\s(?:\<)|(?:<)|(?:")|(?:["]))(?!(?:To:)\s(?:\<)|(?:<)|(?:")|(?:["]))(?!(?:Reply\-To:)\s(?:\<)|(?:<)|(?:")|(?:["]))(?!(?:X\-Sender:)\s(?:\<)|(?:<)|(?:")|(?:["]))(?!(?:Return\-Path:)\s(?:\<)|(?:<)|(?:")|(?:["]))(?!(?:Received\-SPF:))[^\r\n]*)(?P<wtf>(?:(?:\"(?P<display_name>[^\"\r\n]*)\"\s*)?\b(?P<email>(?P<username>[A-Z0-9._%-]+)@(?P<domain_name>(?P<host>(?:[A-Z0-9.-]+\.)*)?(?P<sld>[A-Z0-9.-]+)\.(?P<tld>[A-Z]{2,4})))\b)\h*)(?P<trailing_data>[^\r\n]*))$" & @CRLF & _
"" & @CRLF & _
"(this is a group)?" & @CRLF & _
"" & @CRLF & _
"(another group (with a group inside)) and soem bogus test (and then another group)" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"(?P<group_definition>" & @CRLF & _
" (?P<pattern>" & @CRLF & _
" \(" & @CRLF & _
" (?:[^\)\(]*(?R)*)*" & @CRLF & _
" \)" & @CRLF & _
" )" & @CRLF & _
" (?P<quantifier>" & @CRLF & _
" (?:[\*\+\?])|" & @CRLF & _
" (?:" & @CRLF & _
" \{(?P<min>\d*)" & @CRLF & _
" (?:" & @CRLF & _
" ," & @CRLF & _
" (?P<max>\d*)?" & @CRLF & _
" )?" & @CRLF & _
" \}" & @CRLF & _
" )" & @CRLF & _
" )?" & @CRLF & _
")"
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