#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?s)\nclass\s(.*?)(?=\().*?model\s=\s(.*?)\n.*?(?=fields.*?\((.*?)\)).*?(?=write_once_fields.*?\((.*?)\)).*?(?=required_fields.*?\((.*?)\))"
Local $sString = "import stuff" & @CRLF & _
"" & @CRLF & _
"class ITEM1(BaseSerializer):" & @CRLF & _
" '''docstring'''" & @CRLF & _
" profile_id = None" & @CRLF & _
" house_id = None" & @CRLF & _
" # synopsis = ModelIDListField(source='synopsis', serializer=NotificationSerializer)" & @CRLF & _
" class Meta:" & @CRLF & _
" '''docstring'''" & @CRLF & _
"# model = Null" & @CRLF & _
" model = ITEM2" & @CRLF & _
" fields = (ITEM3)" & @CRLF & _
" # write_once_fields = (Null)" & @CRLF & _
" write_once_fields = (ITEM4)" & @CRLF & _
" required_fields = (ITEM5)" & @CRLF & _
" depth = 1" & @CRLF & _
"" & @CRLF & _
"class ITEM1(HouseUserSerializer):" & @CRLF & _
" # synopsis = ModelIDListField(source='synopsis')" & @CRLF & _
" class Meta:" & @CRLF & _
"# model = Null" & @CRLF & _
" model = ITEM2" & @CRLF & _
" fields = (ITEM3)" & @CRLF & _
" required_fields = (ITEM5)" & @CRLF & _
" depth = 1"
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