#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)<div(?:[^<]+|(?!</?div).|(?R))*+</div>\s*"
Local $sString = "<p>text</p>" & @CRLF & _
"<div class="bad">dsfdag</div>" & @CRLF & _
"<p>TEXT</p>" & @CRLF & _
"<div class="entry">" & @CRLF & _
" <div class="uptl">" & @CRLF & _
" <ul>" & @CRLF & _
" <li>1</li>" & @CRLF & _
" <li>2</li>" & @CRLF & _
" <li>3</li>" & @CRLF & _
" <li>4</li>" & @CRLF & _
" </ul>" & @CRLF & _
" <p>test</p>" & @CRLF & _
" <a href="#">link</a>" & @CRLF & _
" <p>test</p>" & @CRLF & _
" </div>" & @CRLF & _
" <p>test1</p>" & @CRLF & _
"</div>" & @CRLF & _
"<p>test3</p>" & @CRLF & _
"<p>test4</p>"
Local $sSubst = ""
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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