#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?:(?:[-\w\d?*.+|{}\\\/\s<>\]])|(?:\\[\[\]()])|^[\[(].+?[\])])+\s*(#+.*)$"
Local $sString = "(\h{8}-\h{4}-\h{4}-\h{4}-\h{12}) # match UUID (no square brackets at all)" & @CRLF & _
"([A-Za-z_][A-Za-z0-9_]*) # valid Python identifier (paired unescaped square brackets)" & @CRLF & _
"(\||\[|\?) # match some stuff (escaped opening square bracket)" & @CRLF & _
"" & @CRLF & _
"[A-Za-z # letters" & @CRLF & _
"0-9_-.] ### stuff" & @CRLF & _
"" & @CRLF & _
"(\[ # works if escaped [ is in group" & @CRLF & _
"" & @CRLF & _
"\[ # and on its own..." & @CRLF & _
"" & @CRLF & _
"if | pass | raise | return | try | while | with # this should be a comment" & @CRLF & _
"" & @CRLF & _
"\h # a hex digit"
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