#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?x)(?(DEFINE)" & @CRLF & _
"# JSON does not need backtracking if it's valid" & @CRLF & _
"# so everything is atomic to prevent backtracking" & @CRLF & _
"# regex is built per https://tools.ietf.org/html/rfc8259" & @CRLF & _
"(?<json>(?>\s*(?&object)\s*|\s*(?&array)\s*))" & @CRLF & _
"(?<object>(?>\{\s*(?>(?&member)(?>\s*,\s*(?&member))*)?\s*\}))" & @CRLF & _
"(?<member>(?>(?&string)\s*:\s*(?&value)))" & @CRLF & _
"(?<array>(?>\[\s*(?>(?&value)(?>\s*,\s*(?&value))*)?\s*\]))" & @CRLF & _
"(?<value>(?>)false|null|true|(?&object)|(?&array)|(?&number)|(?&string))" & @CRLF & _
"(?<number>(?>-?(?>0|[1-9][0-9]*)(?>\.[0-9]+)?(?>[eE][-+]?[0-9]+)?))" & @CRLF & _
"(?<string>(?>"(?>\\(?>["\\\/bfnrt]|u[a-fA-F0-9]{4})|[^"\\\0-\x1F\x7F]+)*"))" & @CRLF & _
")" & @CRLF & _
"\A(?&json)\z" & @CRLF & _
""
Local $sString = "[" & @CRLF & _
" "JSON Test Pattern pass1"," & @CRLF & _
" {"object with 1 member":["array with 1 element"]}," & @CRLF & _
" {}," & @CRLF & _
" []," & @CRLF & _
" -42," & @CRLF & _
" true," & @CRLF & _
" false," & @CRLF & _
" null," & @CRLF & _
" {" & @CRLF & _
" "integer": 1234567890," & @CRLF & _
" "real": -9876.543210," & @CRLF & _
" "e": 0.123456789e-12," & @CRLF & _
" "E": 1.234567890E+34," & @CRLF & _
" "": 23456789012E66," & @CRLF & _
" "zero": 0," & @CRLF & _
" "one": 1," & @CRLF & _
" "space": " "," & @CRLF & _
" "quote": "\""," & @CRLF & _
" "backslash": "\\"," & @CRLF & _
" "controls": "\b\f\n\r\t"," & @CRLF & _
" "slash": "/ & \/"," & @CRLF & _
" "alpha": "abcdefghijklmnopqrstuvwyz"," & @CRLF & _
" "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ"," & @CRLF & _
" "digit": "0123456789"," & @CRLF & _
" "0123456789": "digit"," & @CRLF & _
" "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?"," & @CRLF & _
" "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A"," & @CRLF & _
" "true": true," & @CRLF & _
" "false": false," & @CRLF & _
" "null": null," & @CRLF & _
" "array":[ ]," & @CRLF & _
" "object":{ }," & @CRLF & _
" "address": "50 St. James Street"," & @CRLF & _
" "url": "http://www.JSON.org/"," & @CRLF & _
" "comment": "// /* <!-- --"," & @CRLF & _
" "# -- --> */": " "," & @CRLF & _
" " s p a c e d " :[1,2 , 3" & @CRLF & _
"" & @CRLF & _
"," & @CRLF & _
"" & @CRLF & _
"4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7]," & @CRLF & _
" "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}"," & @CRLF & _
" "quotes": "" \u0022 %22 0x22 034 ""," & @CRLF & _
" "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"" & @CRLF & _
": "A key can be any string"" & @CRLF & _
" }," & @CRLF & _
" 0.5 ,98.6" & @CRLF & _
"," & @CRLF & _
"99.44" & @CRLF & _
"," & @CRLF & _
"" & @CRLF & _
"1066," & @CRLF & _
"1e1," & @CRLF & _
"0.1e1," & @CRLF & _
"1e-1," & @CRLF & _
"1e00,2e+00,2e-00" & @CRLF & _
","rosebud"]"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH)
; 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