#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?P<function>def\s+(?P<function_name>\w+)\s*\((?P<parameters>(?:.|\n)*?)\):\s*(?:\n[ \t]+.*?)*\n)"
Local $sString = "def sample_function1(arg1, arg2):" & @CRLF & _
" result = arg1 + arg2" & @CRLF & _
" if result > 10:" & @CRLF & _
" print("Greater than 10")" & @CRLF & _
" else:" & @CRLF & _
" print("Not greater than 10")" & @CRLF & _
" return result" & @CRLF & _
"" & @CRLF & _
"def sample_function2(arg1, arg2):" & @CRLF & _
" result = arg1 - arg2" & @CRLF & _
" if result < 0:" & @CRLF & _
" print("Negative result")" & @CRLF & _
" else:" & @CRLF & _
" print("Non-negative result")" & @CRLF & _
" return result" & @CRLF & _
"" & @CRLF & _
"def sample_function3(arg1, " & @CRLF & _
" arg2):" & @CRLF & _
" result = arg1 + arg2" & @CRLF & _
" if result > 10:" & @CRLF & _
" print("Greater than 10")" & @CRLF & _
" else:" & @CRLF & _
" print("Not greater than 10")" & @CRLF & _
" return result" & @CRLF & _
"" & @CRLF & _
"class SampleClass1:" & @CRLF & _
" def __init__(self, arg1, arg2):" & @CRLF & _
" self.arg1 = arg1" & @CRLF & _
" self.arg2 = arg2" & @CRLF & _
"" & @CRLF & _
" def sample_method1(self):" & @CRLF & _
" result = self.arg1 + self.arg2" & @CRLF & _
" return result" & @CRLF & _
"" & @CRLF & _
"class SampleClass2:" & @CRLF & _
" def __init__(self, " & @CRLF & _
" arg1, " & @CRLF & _
" arg2):" & @CRLF & _
" self.arg1 = arg1" & @CRLF & _
" self.arg2 = arg2" & @CRLF & _
"" & @CRLF & _
" def sample_method1(self):" & @CRLF & _
" result = self.arg1 + self.arg2" & @CRLF & _
" return result" & @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