#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?im)^PROC SQL;.*\n(?:(?!RUN;|QUIT;).*\n)*(?:RUN|QUIT);"
Local $sString = "kkkkk;" & @CRLF & _
"" & @CRLF & _
" select xx("xE'", PUT(xx.xxxx.),"'") jdfjhf:jhfjj from xxxx_x_xx_L ;" & @CRLF & _
"quit; " & @CRLF & _
"" & @CRLF & _
"/* 1.xxxxx FROM xxxx_x_Ex_x */ " & @CRLF & _
"proc sql; ("TRUuuuth");" & @CRLF & _
"hhhjhfjs as fdsjfsj:" & @CRLF & _
"select * from djfkjd to jfkjs" & @CRLF & _
"(" & @CRLF & _
"SELECT abc AS abc1, abc_2_ AS efg, abc_fg, fkdkfj_vv, jjsflkl_ff, fjkdsf_jfkj" & @CRLF & _
" FROM &xxx..xxx_xxx_xxE" & @CRLF & _
"where ((xxx(xx_ix as format 'xxxx-xx') gff &jfjfsj_jfjfj.) and " & @CRLF & _
" (xxx(xx_ix as format 'xxxx-xx') lec &jgjsd_vnv.))" & @CRLF & _
" );" & @CRLF & _
"" & @CRLF & _
"1)" & @CRLF & _
"" & @CRLF & _
"jjjjjj;" & @CRLF & _
"" & @CRLF & _
" select xx("xE'", PUT(xx.xxxx.),"'") jdfjhf:jhfjj from xxxx_x_xx_L ;" & @CRLF & _
"quit; " & @CRLF & _
"" & @CRLF & _
"/* 1.xxxxx FROM xxxx_x_Ex_x */ ()" & @CRLF & _
"PROC SQL; ("CUuuiiiiuth");" & @CRLF & _
"hhhjhfjs as fdsjfsj:" & @CRLF & _
"select * from djfkjd to jfkjs" & @CRLF & _
"(SELECT abc AS abc1, abc_2_ AS efg, abc_fg, fkdkfj_vv, jjsflkl_ff, fjkdsf_jfkj" & @CRLF & _
" FROM &xxx..xxx_xxx_xxE" & @CRLF & _
"where ((xxx(xx_ix as format 'xxxx-xx') gff &jfjfsj_jfjfj.) and " & @CRLF & _
" (xxx(xx_ix as format 'xxxx-xx') lec &jgjsd_vnv.))(( ))" & @CRLF & _
" );" & @CRLF & _
"" & @CRLF & _
"2)(" & @CRLF & _
"" & @CRLF & _
"RUN;" & @CRLF & _
"" & @CRLF & _
"())" & @CRLF & _
"" & @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