#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?s)(?(?=\A).*?<script[^>]*>).*?(?:\K\/\/|<\/script>.*?(?:<script[^>]*>|\z)(*SKIP)(*FAIL))"
Local $sString = "Goal: Search using regex (in PowerShell) to find and highlight the JS comments within HTML script tags." & @CRLF & _
"" & @CRLF & _
"TEST#1:" & @CRLF & _
"don't match // dont find this comment here" & @CRLF & _
"don't match https://somesite.com" & @CRLF & _
"" & @CRLF & _
"<script>" & @CRLF & _
"// find this comment here" & @CRLF & _
"//find this comment here" & @CRLF & _
"</script>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"TEST#2:" & @CRLF & _
"<script>" & @CRLF & _
"passover //find this comment here" & @CRLF & _
"</script>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"TEST#3:" & @CRLF & _
"<script>" & @CRLF & _
"// find this comment here" & @CRLF & _
"</script>" & @CRLF & _
"// dont find this comment here" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"TEST#4:" & @CRLF & _
"<script>" & @CRLF & _
"passover" & @CRLF & _
"// find this comment here" & @CRLF & _
"passover" & @CRLF & _
"//find this comment here" & @CRLF & _
"</script>" & @CRLF & _
"//dont find this comment here" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"TEST#5:" & @CRLF & _
"<script>" & @CRLF & _
"passover" & @CRLF & _
"https://somesite.com" & @CRLF & _
"dont find url" & @CRLF & _
"passover" & @CRLF & _
"</script>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"TEST#6:" & @CRLF & _
"<script passover>" & @CRLF & _
"passover" & @CRLF & _
"// find this comment here" & @CRLF & _
"passover" & @CRLF & _
"passover" & @CRLF & _
"//find this comment here" & @CRLF & _
"</script>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"TEST#7:" & @CRLF & _
"<ScRiPt>" & @CRLF & _
"passover //find this comment here with this included also!" & @CRLF & _
"passover this text" & @CRLF & _
"</sCrIpT>" & @CRLF & _
"" & @CRLF & _
"//dont find this comment here" & @CRLF & _
""
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