#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?x:#sds" & @CRLF & _
")" & @CRLF & _
"(?#sdsa)" & @CRLF & _
"#sda" & @CRLF & _
"(?x) # extended mode)" & @CRLF & _
"(?<!\\) # no escape in before paren)" & @CRLF & _
"(?: # begine or end alternation noncap group)" & @CRLF & _
" (?<begin>\( # begining pattern paren)" & @CRLF & _
" (?: # name/index/noncap alternation noncap group)" & @CRLF & _
" (?<named>\?\< # named ?<name>)" & @CRLF & _
" (?<name>[\w][\w\d_]+) # capture name)" & @CRLF & _
" >)| # end of name >)" & @CRLF & _
" (?<indexed>(?!\?))| # indexed capture group no following ? after paren)" & @CRLF & _
" (?<nonecap>\?[^<]) # other groups that dont capture no following < after paren)" & @CRLF & _
" ) # name/index/noncap alternation noncap group)" & @CRLF & _
" )| # begining pattern end)" & @CRLF & _
" (?<end>\)) # ending paren ends group scope)" & @CRLF & _
")"
Local $sString = "(?x) # extended mode" & @CRLF & _
"(?<!\\) # no escape in before paren" & @CRLF & _
"(?: # begine or end alternation noncap group" & @CRLF & _
" (?<begin>\( # begining pattern paren" & @CRLF & _
" (?: # name/index/noncap alternation noncap group" & @CRLF & _
" (?<named>\?\< # named ?<name>" & @CRLF & _
" (?<name>[\w][\w\d_]+) # capture name" & @CRLF & _
" >)| # end of name >" & @CRLF & _
" (?<indexed>(?!\?))| # indexed capture group no following ? after paren" & @CRLF & _
" (?<nonecap>\?[^<]) # other groups that dont capture no following < after paren" & @CRLF & _
" ) # name/index/noncap alternation noncap group" & @CRLF & _
" )| # begining pattern end" & @CRLF & _
" (?<end>\)) # ending paren ends group scope" & @CRLF & _
")"
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