#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(/\*[\s\S]*?\*/|\/\/.*?$|\/\/.*?\n)*(#ifdef BUILD_FLAG\r?\n(?:.*\r?\n)*?#endif\r?\n)" & @CRLF & _
""
Local $sString = " Code here" & @CRLF & _
" and here" & @CRLF & _
"" & @CRLF & _
"//this is s comment block" & @CRLF & _
"/**" & @CRLF & _
"*and a nested comment block" & @CRLF & _
"*/" & @CRLF & _
"" & @CRLF & _
"//-----------------------------------------------------------------------------" & @CRLF & _
"// this comment block should not be captured" & @CRLF & _
"//-----------------------------------------------------------------------------" & @CRLF & _
"" & @CRLF & _
"//-----------------------------------------------------------------------------" & @CRLF & _
"// this whole comment block and the conditional block below should be captured" & @CRLF & _
"//-----------------------------------------------------------------------------" & @CRLF & _
"/**" & @CRLF & _
" * @brief Some comment " & @CRLF & _
" * " & @CRLF & _
" *" & @CRLF & _
" * @return " & @CRLF & _
" */" & @CRLF & _
"//-----------------------------------------------------------------------------" & @CRLF & _
"#ifdef BUILD_FLAG" & @CRLF & _
"..." & @CRLF & _
"#endif" & @CRLF & _
"" & @CRLF & _
" More code" & @CRLF & _
"More code" & @CRLF & _
"" & @CRLF & _
"//---------------------------------------------------------" & @CRLF & _
"// this whole comment block and the conditional block below should be captured" & @CRLF & _
"// --------------------------------------------------------" & @CRLF & _
"#ifdef BUILD_FLAG" & @CRLF & _
"..." & @CRLF & _
"#endif" & @CRLF & _
"" & @CRLF & _
"More code" & @CRLF & _
"" & @CRLF & _
" //-------------------------------------------------------------------------" & @CRLF & _
" /**" & @CRLF & _
" * @name this whole block comment should be captured." & @CRLF & _
" * @{" & @CRLF & _
" */" & @CRLF & _
"" & @CRLF & _
"#ifdef BUILD_FLAG" & @CRLF & _
"..." & @CRLF & _
"#endif" & @CRLF & _
"" & @CRLF & _
""
Local $sSubst = ""
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