#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "\((?>[^()]|(?R))*\)"
Local $sString = "__DATA__" & @CRLF & _
"always @(posedge clk or negedge rst_n)" & @CRLF & _
"if(!rst_n)begin" & @CRLF & _
" d1 <= 0; //perl_comment_4" & @CRLF & _
" //perl_comment_5" & @CRLF & _
" d2 <= 1 //perl_comment_6" & @CRLF & _
" + 2;" & @CRLF & _
" end" & @CRLF & _
"else if( d3 <= d4 && ( d5 <= 3 ) ) begin" & @CRLF & _
" d6 <= d7 +" & @CRLF & _
" (d8 <= d9 ? 1 : 0);" & @CRLF & _
" //perl_comment_7" & @CRLF & _
" d10 <= d11 <=" & @CRLF & _
" d12" & @CRLF & _
" + d13" & @CRLF & _
" <= d14 ? 1 : 0;" & @CRLF & _
" end"
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