#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?s)\\begin\{[^{}]*}(?:(?!\\(?:end|begin)).|(?R))*\\end\{[^{}]*}"
Local $sString = "meh meh" & @CRLF & _
"" & @CRLF & _
"\begin{itemize}" & @CRLF & _
"\item something1" & @CRLF & _
"\begin{itemize}" & @CRLF & _
"\item something1.1" & @CRLF & _
"\item something1.2" & @CRLF & _
"\end{itemize}" & @CRLF & _
"\item something2" & @CRLF & _
"\begin{itemize}" & @CRLF & _
"\item something2.1" & @CRLF & _
"" & @CRLF & _
"\item something2.2" & @CRLF & _
"\end{itemize}" & @CRLF & _
"\end{itemize}" & @CRLF & _
"" & @CRLF & _
"blah blah" & @CRLF & _
"" & @CRLF & _
"\begin{itemize}" & @CRLF & _
"\item somethingelse1" & @CRLF & _
"\item somethingelse2" & @CRLF & _
"\end{itemize}" & @CRLF & _
"" & @CRLF & _
"the 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