#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mxi)(?(DEFINE)" & @CRLF & _
" (?<expr> \w+ | '[\w\s]*' | "[\s\w]*" | \(\s*(?&expr)\s*\) )" & @CRLF & _
" (?<clause> (?&expr)\s*=\s*(?&expr) )" & @CRLF & _
" (?<case> case \s+ when \s+ (?&clause) \s+ then \s+ (?&expr) \s+ else \s+ (?&expr) \s+ end)" & @CRLF & _
")" & @CRLF & _
"(?i)(\s* (?&case) \s*)+"
Local $sString = "iduser + CaSe WhEn ("end") = 0 THEN 'CASE WHEN' ELSE ' END ' END + sum(iduser ) + CASE WHEN LANGUAGE = 3 THEN 4 ELSE 5 END"
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