#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)[ \t]*(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\([ \t\n]*\"[^\"]*\"[ \t\n]*(,[ \t\n]*\"[^\"]*\")?(,[ \t\n]*[^,\)]*)*\)+[ \t\n]*\{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*"
Local $sString = "TEST_CASE ("test") " & @CRLF & _
"{" & @CRLF & _
" Hello world;" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"TEST_CASE ("test with spaces {} []") " & @CRLF & _
"{" & @CRLF & _
" Hello world;" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"TEST_CASE ("test ) ", "case")" & @CRLF & _
"{" & @CRLF & _
" Hello world;" & @CRLF & _
"}" & @CRLF & _
"TEST_CASE ("test () ")" & @CRLF & _
"{" & @CRLF & _
" Hello world;" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"TEST_CASE("all is good")" & @CRLF & _
"{" & @CRLF & _
" REQUIRE(true);" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"TEMPLATE_TEST_CASE("aa", "[]", int, double, foo) {" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"CATCH_TEMPLATE_TEST_CASE("foo", "[tag]", T1, T2) {" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"CATCH_TEST_CASE("bbb") {" & @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