#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?:(?<=\().+?(?=\))|(?<=\[).+?(?=\]))"
Local $sString = "this is a [sample] string " & @CRLF & _
"with [so.me] special ((words)). and he(r)e's [[another! one]] within double brack[ets." & @CRLF & _
"let's finish] this." & @CRLF & _
"" & @CRLF & _
"#ver 1 - \[(.*?)\] - catch brackets, stop if nl between brackets" & @CRLF & _
"#ver 2 - \[(.*?]*)\] - same" & @CRLF & _
"#ver 3 - \[([^]]+)\] - same, but catch even if nl between brackets" & @CRLF & _
"#ver 4 - \[([^\[\]]*)\] - same" & @CRLF & _
"#ver 5 - (?<=\[).+?(?=\]) - catch inside the brackets, stops at nl" & @CRLF & _
"#ver 6 - (\[(?:\[??[^\[]*?\])) - same as #3" & @CRLF & _
"#ver 7 - (?<=\[).*?(?=\]) - same as # 5" & @CRLF & _
"#ver 8 - ([[][a-z \s]+[]]) - catch only the first, w/ brackets" & @CRLF & _
"#ver 9 - (?:(?<=\().+?(?=\))|(?<=\[).+?(?=\])) - same as #5 but catch () as well"
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