#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?x)---\n ((?!---|hostname:) [^\n]+? (\n|$))+ hostname:[^\n]+.domain.com(\n|$) ((?!---|hostname:) [^\n]+? (\n|$))+ (?=---|$)"
Local $sString = "---" & @CRLF & _
"event: outgoing HTTP response" & @CRLF & _
"timestamp: 2021-10-06T08:15:28.212Z" & @CRLF & _
"remoteAddress: "1.2.3.4"" & @CRLF & _
"hostname: a.b.c.domain.com" & @CRLF & _
"statusCode: 200" & @CRLF & _
"headers:" & @CRLF & _
" content-length: 524" & @CRLF & _
" etc: ..." & @CRLF & _
"body: "blabla (can be multiline and can contain anything)"" & @CRLF & _
"---" & @CRLF & _
"event: outgoing HTTP response" & @CRLF & _
"timestamp: 2021-10-06T08:15:28.212Z" & @CRLF & _
"remoteAddress: "1.2.3.4"" & @CRLF & _
"hostname: a.b.c.different.com" & @CRLF & _
"statusCode: 200" & @CRLF & _
"headers:" & @CRLF & _
" content-length: 524" & @CRLF & _
" etc: ..." & @CRLF & _
"body: "blabla (can be multiline and can contain anything)"" & @CRLF & _
"---" & @CRLF & _
"event: outgoing HTTP response" & @CRLF & _
"timestamp: 2021-10-06T08:15:28.212Z" & @CRLF & _
"remoteAddress: "1.2.3.4"" & @CRLF & _
"hostname: 1.2.3.domain.com" & @CRLF & _
"statusCode: 200" & @CRLF & _
"headers:" & @CRLF & _
" content-length: 524" & @CRLF & _
" etc: ..." & @CRLF & _
"body: "blabla (can be multiline and can contain anything)""
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