#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?<=SUBH2002078568)[\s\S]+?(?=SUBF2002078568)"
Local $sString = "HMT940040324" & @CRLF & _
"SUBH2002078568" & @CRLF & _
"2002078568{1:F01BANK MBI}{2:I940MAP}{4:" & @CRLF & _
"2002078568:20:20210420182417" & @CRLF & _
"2002078568:25:2002078568" & @CRLF & _
"2002078568:28C:00075" & @CRLF & _
"2002078568:60F:D210420IDR0," & @CRLF & _
"2002078568:62F:D210420IDR0," & @CRLF & _
"2002078568-}" & @CRLF & _
"SUBF2002078568" & @CRLF & _
"SUBH2003001298" & @CRLF & _
"2003001298{1:F01BANK MBI}{2:I940MAP}{4:" & @CRLF & _
"2003001298:20:20210420182417" & @CRLF & _
"2003001298:25:2003001298" & @CRLF & _
"2003001298:28C:00075" & @CRLF & _
"2003001298:60F:C210420IDR111520964,38" & @CRLF & _
"2003001298:62F:C210420IDR111520964,38" & @CRLF & _
"2003001298-}" & @CRLF & _
"SUBF2003001298" & @CRLF & _
"SUBH2002078568 // *Added this account from the top*" & @CRLF & _
"2002078568{1:F01BANK MBI}{2:I940MAP}{4:" & @CRLF & _
"2002078568:20:20210420182417" & @CRLF & _
"2002078568:25:2002078568" & @CRLF & _
"2002078568:28C:00075" & @CRLF & _
"2002078568:60F:D210420IDR0," & @CRLF & _
"2002078568:62F:D210420IDR0," & @CRLF & _
"2002078568-}" & @CRLF & _
"SUBF2002078568- // End" & @CRLF & _
"FMT9400000004"
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