#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mx)^(" & @CRLF & _
"( # GENERAL before . (Dot)" & @CRLF & _
" (?!\w+\?) # DO NOT MATCH if contains ?" & @CRLF & _
" [\w\]\)]+ # Word, ] or ) characters 1 or more times" & @CRLF & _
")|" & @CRLF & _
"(?:\((\w+)\))| # BRACKETS ()" & @CRLF & _
"([\w\]\)]+(?![?*+])) # BEFORE . (Dot) with ?, * or +" & @CRLF & _
")"
Local $sString = "abcdef.*g[0abc]{0,5}hi # abcdef" & @CRLF & _
"]1234vac.*12345 # ]1234vac" & @CRLF & _
")1234vac.*12345 # )1234vac" & @CRLF & _
"(abc)+123 # abc" & @CRLF & _
"" & @CRLF & _
"12345[abcde]+12345 # 12345" & @CRLF & _
"123?456 # 12" & @CRLF & _
"123\?456 # 123?456" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"# --- No Prefix ---" & @CRLF & _
"" & @CRLF & _
"[A-z]+12345" & @CRLF & _
"(1234vac.*12345" & @CRLF & _
"[a-z]+"
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