#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?im)((?:\"[^"]*)\s*\")|((?:\'[^']*)\s*\')|((?:\`[^`]*)\s*\`)|((?:\b|\s){1}const\s{1})|((?:\b|\s){1}function\s{1})|((?:\b|\s){1}let\s{1})|(?:\/\/.*$)|(?:\/\*+(?:.|\s)*\*\/)|\s*"
Local $sString = "function myFunction() {" & @CRLF & _
" let carName = "Volvo";" & @CRLF & _
" // code here CAN use carName" & @CRLF & _
"const test = 'string with "quoted substring"'; let airplane = 'fly'" & @CRLF & _
"("and another string th'' as' asd 'ere")" & @CRLF & _
"labelForStrings: {" & @CRLF & _
" `t'is a "string"`" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"/*asd *****" & @CRLF & _
"* 324 @*l;;?\\\" & @CRLF & _
"* multiline comment " & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"*** /" & @CRLF & _
"*/"
Local $sSubst = "$1$2$3$4$5$6"
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