#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?x)(?<key>\w*) # The key." & @CRLF & _
"\s*:\s* # : with optional spaces around." & @CRLF & _
"(?<value> # The value." & @CRLF & _
" # A string value, single or double-quoted:" & @CRLF & _
" (?<quote>["']) # Capture the double or single quote." & @CRLF & _
" (?:\\.|.)*? # Backslash followed by anything or any char, ungreedy." & @CRLF & _
" \k<quote> # The double or single quote captured before." & @CRLF & _
"|" & @CRLF & _
" # Int and float numbers:" & @CRLF & _
" (?<number>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)" & @CRLF & _
"|" & @CRLF & _
" # true, false and null (or other constants):" & @CRLF & _
" (?<constant>true | false | null)" & @CRLF & _
")"
Local $sString = "# OK for very simple stuff, such as this:" & @CRLF & _
"{" & @CRLF & _
" float: 'null'," & @CRLF & _
" another: "foo"," & @CRLF & _
" age: 45," & @CRLF & _
" type: '"simple" \' quote'," & @CRLF & _
" comment: "Hello,\nA backslash \\, a tab \t and a \"dummy\" word.\nOk?"," & @CRLF & _
" important: true," & @CRLF & _
" weight: 69.7," & @CRLF & _
" negative: -2.5" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"Not ok for complex stuff:" & @CRLF & _
"" & @CRLF & _
"{" & @CRLF & _
" subStaff: {" & @CRLF & _
" help: true," & @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