#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)LIST\d+ LIST\d+\R((?!$)\S*(?: +\S+)?(?:\R|\Z))*?(?:(?:(\S+) +(?:\S*\R(?1)*\S* +)?\2\b\R?)|(?:\S+ (\S+)\R(?1)*\3\b))(?1)*"
Local $sString = "LIST1 LIST2" & @CRLF & _
"item1 item2" & @CRLF & _
"item3 item4" & @CRLF & _
"item5 item6" & @CRLF & _
"" & @CRLF & _
"LIST3 LIST4" & @CRLF & _
"item1 item2" & @CRLF & _
"item4" & @CRLF & _
"item2" & @CRLF & _
"" & @CRLF & _
"LIST5 LIST6" & @CRLF & _
"item1 item3" & @CRLF & _
"item2 item4" & @CRLF & _
"item5 item2" & @CRLF & _
"" & @CRLF & _
"LIST7 LIST8" & @CRLF & _
"item1 itemA" & @CRLF & _
"item2 itemB" & @CRLF & _
"item3 itemC" & @CRLF & _
" itemD" & @CRLF & _
" item3" & @CRLF & _
" itemE"
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