#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(\[img\].+\n)(\[img\].+\n)*"
Local $sString = "subject1" & @CRLF & _
"image url follows here" & @CRLF & _
"[img]http:f6.abc.com/246421f..." & @CRLF & _
"[img]http:f6.abc.com/246421d..." & @CRLF & _
"[img]http:f6.abc.com/246421h..." & @CRLF & _
"[img]http:f6.abc.com/246421m..." & @CRLF & _
"download url follows here" & @CRLF & _
"[url]link1[/url]" & @CRLF & _
"" & @CRLF & _
"subject2" & @CRLF & _
"image url follows here" & @CRLF & _
"[img]http:z.uvw.com/7862252..." & @CRLF & _
"[img]http:z.uvw.com/4621017..." & @CRLF & _
"[img]http:z.uvw.com/4728212..." & @CRLF & _
"[img]http:z.uvw.com/78293.5..." & @CRLF & _
"download url follows here" & @CRLF & _
"[url]link2[/url]"
Local $sSubst = "$1"
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