#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)(?:\sfrom\s+(?<from>[^\s*]+)[\s]*(?:(?:[\[\(.]?(?<fromh>.*?)?\.?\ *?[\[\(]?(?<fromip>(?:[0-9a-z]*?[\.\:]+[0-9a-z]*?)+)?[\)\]]+)?)(?=[\s;]+(?:by|with|via|id|for|;)\s*?)|\s+by\s+(?<byv>.*?)(?:\s+?\((?:[a-z\-\.]*?\s+)*?\[?(?<byip>(?:(?:[0-9a-z]*?[\.\:]+[0-9a-z]*?)+))*\]?\)?)?(?=[\s;]+(?:from|with|via|id|for|;)\s*?)|\s+via\s+(?<via>[a-z0-9\.\s]*?)(?=(?:\s*;|[\s]+(?:from|by|with|for|id|;))\s*?)|\swith\s+(?<protocol>(?:.|\s)*?)(?=(?:\s*;|[\s]+(?:from|by|via|for|id|;))\s*?)|\s+id\s+(?<id>[^\s;]+)(?=(?:\s*;|[\s]+(?:from|by|via|with|for|;))\s*?)|\s+for\s+<?(?<for>[^\s;>]+)>?(?=(?:\s*;|[\s]+(?:from|by|via|with|id|;))\s*?)|;\s+(?<date>[a-z]{3},\s+[0-9]{1,2}\s+[a-z]{3,4}\s+[0-9]{4}\s+[0-9]{2}\:[0-9]{2}\:[0-9]{2}\s+(?:-[0-9]{4}\s+)?(?:\([a-z]+\)|\+[0-9]{4}))?\n?)"
Local $sString = "Received: from VE1PR01MB5599.eurprd01.prod.exchangelabs.com " & @CRLF & _
" (aze [2603:10a6:7:7c::43]) by HE1PR0102MB2714.eurprd01.prod.exchangelabs.com with HTTPS via HE1PR0402CA0054.EURPRD04.PROD.OUTLOOK.COM with toto; Thu, 9 Jan 2020 16:34:13 +0000" & @CRLF & _
"" & @CRLF & _
"Received: from relay-in.ohc.cu (relay-in.ohc.cu [127.0.0.1])" & @CRLF & _
" by relay-out.ohc.cu (Postfix) with ESMTP id 69EA722DD" & @CRLF & _
" for <some.email@some.domain>; Thu, 9 Jan 2020 11:29:43 -0500 (CST)" & @CRLF & _
"" & @CRLF & _
"Received: from correo.patrimonio.ohc.cu (unknown [192.168.229.20])" & @CRLF & _
" by relay-out.ohc.cu (Postfix) via hello with ESMTP id B83BA22F5" & @CRLF & _
" for <some.email@some.domain>; Thu, 9 Jan 2020 11:29:36 -0500 (CST)" & @CRLF & _
"" & @CRLF & _
"Received: from correoweb.patrimonio.ohc.cu (unknown [192.168.229.23])" & @CRLF & _
" by correo.patrimonio.ohc.cu (Postfix) with ESMTPA id EC62A232A00A;" & @CRLF & _
" Thu, 9 Jan 2020 11:39:53 -0500 (CST)" & @CRLF & _
"" & @CRLF & _
"Received: from VE1PR01MB5599.eurprd01.prod.exchangelabs.com" & @CRLF & _
" (2603:10a6:7:7c::43) by HE1PR0102MB2714.eurprd01.prod.exchangelabs.com with HTTPS via HE1PR0402CA0054.EURPRD04.PROD.OUTLOOK.COM; Thu, 9 Jan 2020 16:34:13" & @CRLF & _
" +0000" & @CRLF & _
"" & @CRLF & _
"Received: from VI1PR0102CA0029.eurprd01.prod.exchangelabs.com" & @CRLF & _
" (2603:10a6:802::42) by VE1PR01MB5599.eurprd01.prod.exchangelabs.com" & @CRLF & _
" (2603:10a6:803:11f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12; Thu, 9 Jan" & @CRLF & _
" 2020 16:34:13 +0000" & @CRLF & _
"" & @CRLF & _
"Received: from DB5EUR01FT034.eop-EUR01.prod.protection.outlook.com" & @CRLF & _
" (2a01:111:f400:7e02::203) by VI1PR0102CA0029.outlook.office365.com" & @CRLF & _
" (2603:10a6:802::42) with Microsoft SMTP Server (version=TLS1_2," & @CRLF & _
" cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.9 via Frontend" & @CRLF & _
" Transport; Thu, 9 Jan 2020 16:34:13 +0000" & @CRLF & _
"" & @CRLF & _
"Received: from relay-out.ohc.cu (200.55.138.44) by" & @CRLF & _
" DB5EUR01FT034.mail.protection.outlook.com (10.152.4.246) with Microsoft SMTP" & @CRLF & _
" Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id" & @CRLF & _
" 15.20.2623.9 via Frontend Transport; Thu, 9 Jan 2020 16:34:12 +0000" & @CRLF & _
"" & @CRLF & _
"Received: from relay-in.ohc.cu (relay-in.ohc.cu [127.0.0.1])" & @CRLF & _
" by relay-out.ohc.cu (Postfix) with ESMTP id 69EA722DD" & @CRLF & _
" for <some.email@some.domain>; Thu, 9 Jan 2020 11:29:43 -0500 (CST)" & @CRLF & _
"" & @CRLF & _
"Received: from relay-out.ohc.cu ([127.0.0.1])" & @CRLF & _
" by relay-in.ohc.cu (relay-in.ohc.cu [127.0.0.1]) (amavisd-new, port 10024)" & @CRLF & _
" with ESMTP id 7CZku5Y59vGC for <some.email@some.domain>;" & @CRLF & _
" Thu, 9 Jan 2020 11:29:38 -0500 (CST)" & @CRLF & _
"" & @CRLF & _
"Received: from correo.patrimonio.ohc.cu (unknown [192.168.229.20])" & @CRLF & _
" by relay-out.ohc.cu (Postfix) with ESMTP id B83BA22F5" & @CRLF & _
" for <some.email@some.domain>; Thu, 9 Jan 2020 11:29:36 -0500 (CST)" & @CRLF & _
"" & @CRLF & _
"Received: from localhost (localhost.localdomain [127.0.0.1])" & @CRLF & _
" by correo.patrimonio.ohc.cu (Postfix) with ESMTP id 65413232A001" & @CRLF & _
" for <some.email@some.domain>; Thu, 9 Jan 2020 11:40:05 -0500 (CST)" & @CRLF & _
"" & @CRLF & _
"Received: from correo.patrimonio.ohc.cu ([127.0.0.1])" & @CRLF & _
" by localhost (correo.patrimonio.ohc.cu [127.0.0.1]) (amavisd-new, port 10024)" & @CRLF & _
" with ESMTP id hNMp-6lHHtzH for <some.email@some.domain>;" & @CRLF & _
" Thu, 9 Jan 2020 11:40:05 -0500 (CST)" & @CRLF & _
"" & @CRLF & _
"Received: from correoweb.patrimonio.ohc.cu (unknown [192.168.229.23])" & @CRLF & _
" by correo.patrimonio.ohc.cu (Postfix) with ESMTPA id EC62A232A00A;" & @CRLF & _
" Thu, 9 Jan 2020 11:39:53 -0500 (CST)"
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