#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)(<(?!\/)[a-zA-Z\-0-9]+?(?:[\s]*?[a-zA-Z\-0-9]+?(?:=(?:"[\s\S]*?"|'[\s\S]*?')){0,1})*?[\s]*?\/{0,1}>)|(<\/[\S\s]+?>)|(<!--[\s\S]*?-->)"
Local $sString = "<div class="main">" & @CRLF & _
" <div>" & @CRLF & _
" <form id="cadastro">" & @CRLF & _
" <input value="text" />" & @CRLF & _
" </form>" & @CRLF & _
" </div>" & @CRLF & _
" <div>" & @CRLF & _
" <div>" & @CRLF & _
" <h1>Lorem ipsum dolor sit amet</h1>" & @CRLF & _
" <p>Lorem ipsum dolor sit amet</p>" & @CRLF & _
" </div>" & @CRLF & _
" </div>" & @CRLF & _
" <!-- sad asd asdasds adasd -->" & @CRLF & _
"</div>" & @CRLF & _
"<div>" & @CRLF & _
" <ul>" & @CRLF & _
" <li>item 1</li>" & @CRLF & _
" </ul>" & @CRLF & _
" teste" & @CRLF & _
"</div>"
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