#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?s)if\s*(\((?>[^()]|(?1))*\))(*SKIP)(*F)|(\w+)(\s*<=[^;]*)"
Local $sString = "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 $sSubst = "$2_yes$3"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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