#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?x)editor\s*\{[^{}"]*" & @CRLF & _
"" & @CRLF & _
"# Repeatedly match the key-value pairs" & @CRLF & _
"(?:" & @CRLF & _
" # Match from opening to closing double quote for the 'key'" & @CRLF & _
" "[^\\"]*" & @CRLF & _
" # Handle escaped characters: \ followed by another character" & @CRLF & _
" (?: \\. [^\\"]* )*" & @CRLF & _
" "" & @CRLF & _
" # Then any whitespace between the 'key' and 'value'" & @CRLF & _
" \s+" & @CRLF & _
" # Match from opening to closing double quote for the 'value'" & @CRLF & _
" "[^\\"]*" & @CRLF & _
" # Handle escaped characters: \ followed by another character" & @CRLF & _
" (?: \\. [^\\"]* )*" & @CRLF & _
" "" & @CRLF & _
"" & @CRLF & _
" # Match everything (especially whitespace) except these chars:" & @CRLF & _
" [^{}"]*" & @CRLF & _
"" & @CRLF & _
"|" & @CRLF & _
" # Key name may or may not be within quotes" & @CRLF & _
" "? \w+ "? [^{}"]*" & @CRLF & _
" \{[^{}"]*" & @CRLF & _
" (?:" & @CRLF & _
" "[^\\"]* (?: \\. [^\\"]* )* " \s+ "[^\\"]* (?: \\. [^\\"]* )* "" & @CRLF & _
" [^{}"]*" & @CRLF & _
" )*" & @CRLF & _
" \} [^{}"]*" & @CRLF & _
")*" & @CRLF & _
"" & @CRLF & _
"\}"
Local $sString = ""entity"" & @CRLF & _
"{" & @CRLF & _
" "id" "5040044"" & @CRLF & _
" "classname" "weapon_defibrillator_spawn"" & @CRLF & _
" "angles" "0 0 0"" & @CRLF & _
" "body" "0"" & @CRLF & _
" "disableshadows" "0"" & @CRLF & _
" "skin" "0"" & @CRLF & _
" "solid" "6"" & @CRLF & _
" "spawnflags" "3"" & @CRLF & _
" "origin" "449.47 5797.25 2856"" & @CRLF & _
" editor" & @CRLF & _
" {" & @CRLF & _
" "color" "0 0 200"" & @CRLF & _
" "visgroupshown" "1"" & @CRLF & _
" "visgroupautoshown" "1"" & @CRLF & _
" "logicalpos" "[-13268 14500]"" & @CRLF & _
" "helptext" "This is a \"help\" menu."" & @CRLF & _
" }" & @CRLF & _
" editor" & @CRLF & _
" {" & @CRLF & _
" "color" "0 0 200"" & @CRLF & _
" "visgroupshown" "1"" & @CRLF & _
" "visgroupautoshown" "1"" & @CRLF & _
" "logicalpos" "[-13268 14500]"" & @CRLF & _
" }" & @CRLF & _
" editor" & @CRLF & _
" {" & @CRLF & _
" "color" "0 0 200"" & @CRLF & _
" "visgroupshown" "1"" & @CRLF & _
" "visgroupautoshown" "1"" & @CRLF & _
" "logicalpos" "[-13268 14500]"" & @CRLF & _
" "specialchars" "}"" & @CRLF & _
" }" & @CRLF & _
" editor" & @CRLF & _
" {" & @CRLF & _
" "child" "0 0 200"" & @CRLF & _
" "visgroupshown" "1"" & @CRLF & _
" "visgroupautoshown" "1"" & @CRLF & _
" "logicalpos" "[-13268 14500]"" & @CRLF & _
" subgroup" & @CRLF & _
" {" & @CRLF & _
" "child" "42 42 42"" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"}" & @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