#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(<.*Page #.*$)"
Local $sString = " <text:p text:style-name="P27"><text:span text:style-name="T20">Page #</text:span><text:span text:style-name="T19"><text:tab/></text:span><text:span text:style-name="T20">Content</text:span></text:p>" & @CRLF & _
" <text:p text:style-name="P27"><text:span text:style-name="T20">Page #</text:span><text:span text:style-name="T19"><text:tab/></text:span><text:span text:style-name="T20">Content</text:span></text:p>" & @CRLF & _
" <text:p>some other text</text:p>" & @CRLF & _
"<text:p text:style-name="P27"><text:span text:style-name="T20">Page #</text:span><text:span text:style-name="T19"><text:tab/></text:span><text:span text:style-name="T20">Content</text:span></text:p>"
Local $sSubst = "$1\nfoo\nbar\n"
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