#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?x)(?(DEFINE)" & @CRLF & _
" (?<string>'[^']++')" & @CRLF & _
" (?<int>\b\d+\b)" & @CRLF & _
" (?<sp>\s*)" & @CRLF & _
" (?<key>\b\w+\b)" & @CRLF & _
" (?<value>(?&string)|(?&int))" & @CRLF & _
" (?<exp>(?&key) (?&sp) = (?&sp) (?&value))" & @CRLF & _
" (?<logic>\b (?:and|or) \b)" & @CRLF & _
" (?<main>" & @CRLF & _
" (?<token> \( (?&sp) (?&main) (?&sp) \) | (?&exp) )" & @CRLF & _
" (?:" & @CRLF & _
" (?&sp) (?&logic) (?&sp)" & @CRLF & _
" (?&token) " & @CRLF & _
" )*" & @CRLF & _
" )" & @CRLF & _
")" & @CRLF & _
"(?:" & @CRLF & _
" ^ (?&sp) (?= (?&main) (?&sp) $ )" & @CRLF & _
" |" & @CRLF & _
" (?!^) \G" & @CRLF & _
" (?&sp) (?&logic) (?&sp)" & @CRLF & _
")" & @CRLF & _
"(?:" & @CRLF & _
" \( (?&sp) (?<m_main>(?&main)) (?&sp) \)" & @CRLF & _
" |" & @CRLF & _
" (?<m_key>(?&key)) (?&sp) = (?&sp) (?<m_value>(?&value))" & @CRLF & _
")"
Local $sString = "name = 'benjo' and (surname = 'benny' or surname = 'bennie') or age = 4" & @CRLF & _
"or " & @CRLF & _
"name = 'benjo' and (surname = 'benny' or surname = 'bennie') or (age = 4 or age = 6)" & @CRLF & _
"and" & @CRLF & _
"(name = 'benjo' or name='xxx') and (surname = 'benny' or surname = 'bennie') or age = 4"
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