#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?sixuX)(?(DEFINE)" & @CRLF & _
" (?<tagName>" & @CRLF & _
" [a-z][a-z\d]*+ (?=[>\s/])" & @CRLF & _
" )" & @CRLF & _
" (?<tagAttr>" & @CRLF & _
" (?>" & @CRLF & _
" [^>"']++" & @CRLF & _
" | " [^"]*+ "" & @CRLF & _
" | ' [^']*+ '" & @CRLF & _
" )*+" & @CRLF & _
" )" & @CRLF & _
")" & @CRLF & _
"" & @CRLF & _
"< (li|/ul) /?+ (?=[>\s/]) ((?&tagAttr)) >" & @CRLF & _
"((?:" & @CRLF & _
" [^<]++" & @CRLF & _
" | < /?+ (?!(?:li|ul)(?=[>\s/])) (?&tagName) (?&tagAttr) > #any tag except <li> and <ul>" & @CRLF & _
" | < (?! /?+ (?&tagName) ) #not tag" & @CRLF & _
")*)" & @CRLF & _
"(?= < (?:li|/ul) (?=[>\s/]) (?&tagAttr) ) #check for nested <li> and <ul>"
Local $sString = "<ul>" & @CRLF & _
" <li fhgfhfg ghgfhfghhfgh= ghghg="..." a = 'ghghg'>dfdsfsd" & @CRLF & _
" <ul>" & @CRLF & _
" <li>111</li>" & @CRLF & _
" <li/>2222" & @CRLF & _
" <li>mmmmm</li>" & @CRLF & _
" </ul>" & @CRLF & _
" <li>dfdsfdsfsdf <b class="..."><br/>fgdfgd<i></b><!-- dfdf--><li>" & @CRLF & _
" <li>" & @CRLF & _
" <li>dsfsdfsdfdsf" & @CRLF & _
"</ul>" & @CRLF & _
"" & @CRLF & _
""
Local $sSubst = "<$3$4>$5</LI>\r"
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