#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^art(?:\r?\n(?!art-|\s*code:"XXX").*)*\r?\n\s*code:"XXX"(?:\r?\n(?!art-).*)*\r?\nart-"
Local $sString = "begin" & @CRLF & _
"more text " & @CRLF & _
"art" & @CRLF & _
" id:213213" & @CRLF & _
" code:"XXX"" & @CRLF & _
" name:234" & @CRLF & _
"art-" & @CRLF & _
"art" & @CRLF & _
" id:543" & @CRLF & _
" name:72" & @CRLF & _
" code:"AAA"" & @CRLF & _
"art-" & @CRLF & _
"art" & @CRLF & _
" code:"XXX"" & @CRLF & _
" id:32" & @CRLF & _
" name:46" & @CRLF & _
"art-" & @CRLF & _
"art" & @CRLF & _
" code:"CCC"" & @CRLF & _
" id:8765" & @CRLF & _
"art-" & @CRLF & _
"art" & @CRLF & _
" id:876" & @CRLF & _
" code:"DDD"" & @CRLF & _
"art-" & @CRLF & _
"even more text" & @CRLF & _
"even more text" & @CRLF & _
"end"
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