#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?sx)(.*?) # Data before sentences (to be removed)" & @CRLF & _
"( # Capture Both sentences and text in between" & @CRLF & _
" H.*?e.*?l.*?l.*?o.*?\s # Hello[space]" & @CRLF & _
" (<.*?>)* # Optional Opening Tag(s)" & @CRLF & _
" 進.*?撃.*?の.*?巨.*?人.*? # 進撃の巨人" & @CRLF & _
" (<\/.*?>)* # Optional Closing Tag(s)" & @CRLF & _
" (.*?) # Optional Data in between sentences" & @CRLF & _
" (<.*?>)* # Optional Opening Tag(s)" & @CRLF & _
" L.*?o.*?r.*?e.*?m.*?\s # Lorem[space]" & @CRLF & _
" (<.*?>)* # Optional Opening Tag(s)" & @CRLF & _
" i.*?p.*?s.*?u.*?m.*? # ipsum" & @CRLF & _
")" & @CRLF & _
"(.*) # Data after sentences (to be removed)"
Local $sString = "" & @CRLF & _
"<html>" & @CRLF & _
"<body>" & @CRLF & _
"<header>Hello <p> </p> 進撃<em>の巨</人!</em></header>" & @CRLF & _
"random code" & @CRLF & _
"random code" & @CRLF & _
"<p>Lorem <span>ipsum<span>.<p>" & @CRLF & _
"</body>" & @CRLF & _
"</html>"
Local $sSubst = "\2"
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