#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^\s*(Public|Private)?(?:\s*)(Function|Sub)(?:\s*)([a-zA-Z_]\w*)\s*(?:\()([^)]*)(?:\))(?:\sAs\s)?(\w*)?([\s\S]*?)^\s*(?:End Function|End Sub)"
Local $sString = "Attribute VB_Name = "mdl_WbkInits"" & @CRLF & _
"Option Compare Database" & @CRLF & _
"" & @CRLF & _
"Function InitWbk_004(byRef wbkRef As Object)" & @CRLF & _
" Dim wbk As wbk_004_InstoreBrief" & @CRLF & _
"" & @CRLF & _
" Set wbk = New wbk_004_InstoreBrief" & @CRLF & _
"" & @CRLF & _
" Call wbk.wbk_Init(wbkRef)" & @CRLF & _
" " & @CRLF & _
" Set InitWbk_004 = wbk" & @CRLF & _
"End Function" & @CRLF & _
"Public Function InitWbk_003(ByRef wbkRef As Object) As Object" & @CRLF & _
"" & @CRLF & _
" Dim wbk As wbk_003_3DCalculation" & @CRLF & _
"" & @CRLF & _
" Set wbk = New wbk_003_3DCalculation" & @CRLF & _
"" & @CRLF & _
" Call wbk.wbk_Init(wbkRef)" & @CRLF & _
" " & @CRLF & _
" Set InitWbk_003 = wbk" & @CRLF & _
"End Function" & @CRLF & _
""
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