#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?:(?:(?:(?:var|let)[ \t]+)?([\w.\-]+)[ \t]*[:=]|[(!])[ \t]*)function(?:[ \t]+([\w.\-]+))?[ \t]*\([^)]*\)"
Local $sString = "!function(){}() // test1" & @CRLF & _
"!function test2(){}() // test2" & @CRLF & _
"(function(){})() // test3" & @CRLF & _
"(function test4(){})() // test4" & @CRLF & _
"test5 = function(){} // test5" & @CRLF & _
"test6 = function _test6(){} // test6" & @CRLF & _
"let test7 = function(){} // test7" & @CRLF & _
"let test8 = function _test8(){} // test8" & @CRLF & _
"var test9 = function(){} // test8" & @CRLF & _
"var test10 = function _test10(){} // test10" & @CRLF & _
"myfunc(function(){}) // test11" & @CRLF & _
"myfunc(function test12(){}) // test12" & @CRLF & _
"let myobj = {test13 : function(){}} // test13" & @CRLF & _
"let myobj = {test14 : function _test14(){}} // test14" & @CRLF & _
"var myobj = {test15 : function(){}} // test15" & @CRLF & _
"var myobj = {test16 : function _test16(){}} // test16" & @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