#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?:INSERT INTO|UPDATE|SELECT|WITH|DELETE)(?:[^;']|(?:'[^']+'))+;\s*$"
Local $sString = "SELECT * FROM database;" & @CRLF & _
"SELECT * FROM database WHERE somefield = 'somevalue';" & @CRLF & _
"SELECT * FROM database WHERE somefield = 'somevalue' AND someotherfield = 'somemistypedstring;" & @CRLF & _
"" & @CRLF & _
"SELECTing is hard, though, this is just text!;" & @CRLF & _
"" & @CRLF & _
"SELECT" & @CRLF & _
" *" & @CRLF & _
"FROM" & @CRLF & _
" test_table" & @CRLF & _
"WHERE" & @CRLF & _
" test_row = 'Testing ; semicolon';" & @CRLF & _
"" & @CRLF & _
"SELECT * FROM another_test_table;" & @CRLF & _
"" & @CRLF & _
"INSERT INTO " & @CRLF & _
" table_name " & @CRLF & _
"VALUES " & @CRLF & _
" (value1,'value which contains semicolon ;;;;',value3,...);"
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