#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?is)(<script\b[^><]*>)(.*?)(<\/script>)|\bon\w+\s*=\s*\K(?|(\")([^\"]+)\"|(')([^']+)')"
Local $sString = "<div id='content' onClick='abc()'>Lorem On='abc' ipsum on to</div>" & @CRLF & _
"<input id='a' type='range'>" & @CRLF & _
"<input id='b' type='range'>" & @CRLF & _
"<script>abc();</script>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"Jan23: The following is an addition set of tests including escaping quotes and .replace(/'/ situations that can cause problems." & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
" <div id='content'" & @CRLF & _
" onClick='yyy("ere\'xyz\'").value=\'ewew\'; yyy("jhrhej")'" & @CRLF & _
" >Lorem On='abc' ipsum on to</div>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
" <input id='a' type='range'" & @CRLF & _
" onPress="xxx(document.getElementById(\"abc\"))"" & @CRLF & _
" onSomething="yyy(\'fehrje\')"" & @CRLF & _
" onSomethingElse="document.getElementById('content').innerHTML.replace(/"/g, \"dq\")">" & @CRLF & _
" <input id='b' type='range'>" & @CRLF & _
"" & @CRLF & _
" <script>" & @CRLF & _
" function abc() {console.log('abc()');};" & @CRLF & _
" function xxx(elem) {console.log('xxx:'+elem.className);};" & @CRLF & _
" function yyy(str) {console.log('yyy:'+str);};" & @CRLF & _
"" & @CRLF & _
" yyy("ere\'xyz\'");" & @CRLF & _
" yyy("jhrhej");" & @CRLF & _
"" & @CRLF & _
" var aaa=document.getElementById('content').innerHTML;" & @CRLF & _
" var bbb=document.getElementById('content').innerHTML;" & @CRLF & _
" abc();" & @CRLF & _
" aaa.replace(/'/g, "single-quotes");" & @CRLF & _
" bbb.replace(/'/g, 'single-quotes');" & @CRLF & _
" aaa.replace(/"/g, "quotes");" & @CRLF & _
" bbb.replace(/"/g, 'quotes');" & @CRLF & _
" </script>" & @CRLF & _
"" & @CRLF & _
"</body>" & @CRLF & _
"</html>"
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