#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?:q'\[.*?\](?=')'|q'<.*?>(?=')'|q'\(.*?\)(?=')'|q'{.*?}(?=')'|(?!q)'(?:[^']|'')*')"
Local $sString = "q'[Here's Johnny]' + 't''e''s''t]'" & @CRLF & _
"q'<Here's Johnny>'" & @CRLF & _
"q'(Here's Johnny)'.anotherTest('h'')''ere')" & @CRLF & _
"q'{Here's Johnny}'" & @CRLF & _
"'Here''s Johnny'" & @CRLF & _
"q'[Here's J>'}'''ohnny]'" & @CRLF & _
"q'<Here's John'']'}'ny>'" & @CRLF & _
"q'(Here's Johnny)'" & @CRLF & _
"q'{Here's Johnny}'" & @CRLF & _
"'Here''s Johnny'" & @CRLF & _
"DECLARE" & @CRLF & _
" VARCHAR2(1024);" & @CRLF & _
" v_cnt PLS_INTEGER;" & @CRLF & _
" BEGIN" & @CRLF & _
" v_sql := q'[SELECT COUNT(*) FROM user_objects WHERE object_type = 'TABLE']';" & @CRLF & _
" EXECUTE IMMEDIATE v_sql INTO v_cnt;" & @CRLF & _
" DBMS_OUTPUT.PUT_LINE(" & @CRLF & _
" TO_CHAR(v_cnt) || ' tables in USER_OBJECTS.'" & @CRLF & _
" );" & @CRLF & _
" END;" & @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