#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(<(\w+)>)\s*(.*?)\s*(<\/\2>)"
Local $sString = "<h1>" & @CRLF & _
"<page num="1" />" & @CRLF & _
"<b><i>Britons United By Lost Hope, If Nothing Else</i></b>" & @CRLF & _
"</h1>" & @CRLF & _
"<h2>" & @CRLF & _
"<b><i>Many Feel Brexit Has Democracy on Trial</i></b>" & @CRLF & _
"</h2>" & @CRLF & _
"<h3>" & @CRLF & _
"<page num="18" />" & @CRLF & _
"<b><i>Britons Are Feeling United by a Lost Hope in Democracy, if Nothing Else</i></b>" & @CRLF & _
"</h3>" & @CRLF & _
"<fig>" & @CRLF & _
"<img src="images/img_103-5.jpg" width="442" height="261" alt="" />" & @CRLF & _
"<fc>Ann Dwyer, Thomas Dunn</fc>" & @CRLF & _
"<cr>AMANDA REYNOLDS OF PLUME PHOTOGRAPHY</cr>" & @CRLF & _
"</fig>" & @CRLF & _
"</break>"
Local $sSubst = "\1\3\4"
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