#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mix)(?(DEFINE)" & @CRLF & _
" (?<tagnames> @CUSTOM-AT-1 | @CUSTOM-AT-2)" & @CRLF & _
" (?<number> -? (?= [1-9]|0(?!\d) ) \d+ (\.\d+)? ([eE] [+-]? \d+)? )" & @CRLF & _
" (?<boolean> true | false | null )" & @CRLF & _
" (?<string> \" ([^\"\\\\]* | \\\\ [\"\\\\bfnrt\/] | \\\\ u [0-9a-f]{4} )* \" )" & @CRLF & _
" (?<array> \[ (?: (?&json) (?: , (?&json) )* )? \s* \] )" & @CRLF & _
" (?<pair> \s* (?&string) \s* : (?&json) )" & @CRLF & _
" (?<object> \{ (?: (?&pair) (?: , (?&pair) )* )? \s* \} )" & @CRLF & _
" (?<fieldname> [a-zA-Z0-9\_\-]+ )" & @CRLF & _
" (?<json> \s* (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )" & @CRLF & _
" (?<fieldlist> (?: (?&fieldname) (?: , (?&fieldname) )+ )+ ) )" & @CRLF & _
" (?<actiontag> (?&tagnames)" & @CRLF & _
")" & @CRLF & _
"(?:\=" & @CRLF & _
" (?'params'" & @CRLF & _
" (?:" & @CRLF & _
" (?'match_list'(?&fieldlist))" & @CRLF & _
" |" & @CRLF & _
" (?'match_json'(?&json))" & @CRLF & _
" |" & @CRLF & _
" (?'match_string'(?:[[:alnum:]\_\-]+))" & @CRLF & _
" )" & @CRLF & _
" )" & @CRLF & _
")"
Local $sString = "@FIELDLIST=field_1,field_2" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"@STRING="Bar"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"@JSON={"foo":"bar"}" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"@CUSTOM-AT-2={"strict":true, "targets":["field_3", "field_7"], "title":"Custom Title", "message":"This is a custom message"}" & @CRLF & _
"" & @CRLF & _
"@CUSTOM-AT-1={"strict":true, "targets":["field_3", "field_7"], "title":"Custom Title", "message":"This is a custom message"}"
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