#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "((['"])(?:(?!\2|\\).|\\.)*\2)|\/\/[^\n]*|\/\*(?:[^*]|\*(?!\/))*\*\/"
Local $sString = "String somestring = "http://google.com"; // "//google.com";" is going to be removed" & @CRLF & _
"" & @CRLF & _
"get.setHeader("Accept", "*/*"); // "/*");" and later is going to be removed too" & @CRLF & _
"" & @CRLF & _
"somemethod();//it should be removed" & @CRLF & _
"somemethod(); /* some comment that may end on other line */" & @CRLF & _
"String somestring = "http://google.com"; // url shouldn't be touched" & @CRLF & _
"get.setHeader("Accept", "*/*"); // "*/*" shouldn't be touched too"
Local $sSubst = "$1"
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