#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)<\/?html.*?>"
Local $sString = "<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">" & @CRLF & _
"<head>" & @CRLF & _
"some head info " & @CRLF & _
"</head>" & @CRLF & _
"<body>" & @CRLF & _
"<div > some content with other HTML tags that I want to preserve </div>" & @CRLF & _
"<body>" & @CRLF & _
"</html>" & @CRLF & _
"<html>" & @CRLF & _
"<div> another content with other HTML tags that I want to preserve </div>" & @CRLF & _
"</html>" & @CRLF & _
"<html xmlns="http://www.w3.org/TR/REC-html40">" & @CRLF & _
"<head>" & @CRLF & _
"some head info " & @CRLF & _
"</head>" & @CRLF & _
"<body>" & @CRLF & _
"<div> some other content with other HTML tags that I want to preserve </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