#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(<p>|<div .*>)(\s*)(<a .*>)?(\s*)(<img .* \/>)(\s*)(<\/a>)?(\s*)(<p .*>.*<\/p>)?(\s*)(<\/p>|<\/div>)"
Local $sString = "<div id="attachment_3340" style="width: 865px" class="wp-caption alignnone">" & @CRLF & _
" <img class="size-full wp-image-3340" alt="Testbild" src="https://beispiel.de/images/Testbild.jpg" width="855" height="631" />" & @CRLF & _
" <p class="wp-caption-text">© Copyright</p>" & @CRLF & _
"</div>"
Local $sSubst = "$3$5$7$9"
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