#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)\/\*[\s\S]*?\*\/|(?<=[^:])\/\/.*|^\/\/.*"
Local $sString = "// other comment" & @CRLF & _
"//test" & @CRLF & _
"here /*test*/" & @CRLF & _
"alert('hello, this code has comments!')//An alert" & @CRLF & _
"/* A block comment here */" & @CRLF & _
"// A single line comment on a newline" & @CRLF & _
"/*" & @CRLF & _
"multiple lines*/" & @CRLF & _
"/** double asterisks */" & @CRLF & _
"//" & @CRLF & _
"some text" & @CRLF & _
"/**/" & @CRLF & _
"/*" & @CRLF & _
" * multiple lines again" & @CRLF & _
"*/" & @CRLF & _
"some text" & @CRLF & _
"/* here / there */" & @CRLF & _
"var url="https://www.website.com";//comment"
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