#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?s)\<script\>[^<]*?(findthis).*?\<\/script\>"
Local $sString = "<html>" & @CRLF & _
" <head>" & @CRLF & _
" <script>" & @CRLF & _
" var x = 1;" & @CRLF & _
" var y = 'findthis'; // Should be matched" & @CRLF & _
" </script>" & @CRLF & _
" </head>" & @CRLF & _
" <body>" & @CRLF & _
" <script>" & @CRLF & _
" var a = 2;" & @CRLF & _
" </script>" & @CRLF & _
"" & @CRLF & _
" <h1>Welcome!</h1>" & @CRLF & _
" <p>This findthis here should not be matched.</p>" & @CRLF & _
"" & @CRLF & _
" <script>" & @CRLF & _
" var b = 'findthis too'; // Should be matched, too." & @CRLF & _
" </script>" & @CRLF & _
"" & @CRLF & _
" <div>" & @CRLF & _
" <p>This findthis should not be matched neither.</p>" & @CRLF & _
" </div>" & @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