#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?x)([^\s:,]+)(?#get field)" & @CRLF & _
":[ ]*(?#get separator)" & @CRLF & _
"([^,\{\}\n\[\]\s][^,\n]*)(?#get value)"
Local $sString = "{" & @CRLF & _
" field-1: "field value 1"," & @CRLF & _
" field2:"field 2","fieldThree": "value field param {three} "," & @CRLF & _
" "subobject":{" & @CRLF & _
" "subfield1":1.1," & @CRLF & _
" "sub-field-2":"subval [1.2]"," & @CRLF & _
" "sub-subobject":{" & @CRLF & _
" "sub_subfield1":"sub sub field 1 ~"," & @CRLF & _
" "sub_subfield2":"sub sub field 2 !@#$%/"" & @CRLF & _
" }" & @CRLF & _
" }," & @CRLF & _
" "array":[" & @CRLF & _
" { objectA:01, objectAA:02 }," & @CRLF & _
" { objectB:01, objectBB:02 }" & @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