#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?sm)\A.*?(?=message)"
Local $sString = "package grpc;" & @CRLF & _
"" & @CRLF & _
"import "envoyproxy/protoc-gen-validate/validate/validate.proto";" & @CRLF & _
"import "google/api/annotations.proto";" & @CRLF & _
"import "google/protobuf/wrappers.proto";" & @CRLF & _
"import "protoc-gen-swagger/options/annotations.proto";" & @CRLF & _
"" & @CRLF & _
"message Acc {" & @CRLF & _
" message AccErr {" & @CRLF & _
" enum Enum {" & @CRLF & _
" UNKNOWN = 0;" & @CRLF & _
" CASH = 1;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" string account_id = 1;" & @CRLF & _
" string name = 3;" & @CRLF & _
" string account_type = 4;" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"message Name {" & @CRLF & _
" string firstname = 1;" & @CRLF & _
" string lastname = 2;" & @CRLF & _
"}" & @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