#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?:(?=(?&V_Obj)){|(?!^)\G(?&Sep_Obj)\s*)(?:(?&V_KeyVal)(?&Sep_Obj))*?\s*(?&Str)\s*:\s*\K(?&Numb)(?(DEFINE)(?<Sep_Ary>\s*(?:,(?!\s*[}\]])|(?=\])))(?<Sep_Obj>\s*(?:,(?!\s*[}\]])|(?=})))(?<Er_Obj>(?>{(?:\s*(?&Str)(?:\s*:(?:\s*(?:(?&Er_Value)|(?<Er_Ary>\[(?:\s*(?:(?&Er_Value)|(?&Er_Ary)|(?&Er_Obj))(?:(?&Sep_Ary)|(*ACCEPT)))*(?:\s*\]|(*ACCEPT)))|(?&Er_Obj))(?:(?&Sep_Obj)|(*ACCEPT))|(*ACCEPT))|(*ACCEPT)))*(?:\s*}|(*ACCEPT))))(?<Er_Value>(?>(?&Numb)|(?>true|false|null)|(?&Str)))(?<Str>(?>"[^\\"]*(?:\\[\s\S][^\\"]*)*"))(?<Numb>(?>[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|(?:[eE][+-]?\d+)))(?<V_KeyVal>(?>\s*(?&Str)\s*:\s*(?&V_Value)\s*))(?<V_Value>(?>(?&Numb)|(?>true|false|null)|(?&Str)|(?&V_Obj)|(?&V_Ary)))(?<V_Ary>\[(?>\s*(?&V_Value)(?&Sep_Ary))*\s*\])(?<V_Obj>{(?>(?&V_KeyVal)(?&Sep_Obj))*\s*}))"
Local $sString = "{" & @CRLF & _
" "first_name":"sample"," & @CRLF & _
" "last_name": "lastname"," & @CRLF & _
" "integer" : 100," & @CRLF & _
" "float" : 1555.20," & @CRLF & _
" "createddate":"2015-06-25 09:57:28"," & @CRLF & _
" "asder" : " & @CRLF & _
" [ " & @CRLF & _
" 200, " & @CRLF & _
" 100," & @CRLF & _
" {" & @CRLF & _
" "nother1" : "here"," & @CRLF & _
" "digi1" : 900e10," & @CRLF & _
" "nother1" : "here"," & @CRLF & _
" "digi2" : 3.14" & @CRLF & _
" }," & @CRLF & _
" 400," & @CRLF & _
" 37" & @CRLF & _
" ]" & @CRLF & _
"}"
Local $sSubst = ""$0""
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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