#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)\bItem\s+5\.02\s*([\w\W]*?)(?=\s*(?:Item\s+(?:[89]\.01|5\.0[37])|SIGNATURES?|Pursuant\s+to\s+the\s+requirements\s+of\s+the\s+Securities\s+Exchange\s+Act\s+of\s+1934)\b)"
Local $sString = "Item 5.02 text" & @CRLF & _
"text" & @CRLF & _
"text" & @CRLF & _
" Item 8.01" & @CRLF & _
"Item 5.02 text" & @CRLF & _
"text" & @CRLF & _
" Item 9.01" & @CRLF & _
"Item 5.02 text" & @CRLF & _
"text" & @CRLF & _
" Item 5.03" & @CRLF & _
"Item 5.02 text" & @CRLF & _
"text" & @CRLF & _
" Item 5.07" & @CRLF & _
"Item 5.02 text" & @CRLF & _
"text" & @CRLF & _
" SIGNATURES" & @CRLF & _
"Item 5.02 text" & @CRLF & _
"text" & @CRLF & _
" SIGNATURE" & @CRLF & _
"Item 5.02 text" & @CRLF & _
"text" & @CRLF & _
" Pursuant to the requirements of" & @CRLF & _
" the Securities Exchange Act of 1934"
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