#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?is)<img[^>]*src="([^"]+)"[^>]*>|<a\b.+?</a>(*SKIP)(*F)"
Local $sString = "" & @CRLF & _
" <img src="/img/file1.jpg" />" & @CRLF & _
"" & @CRLF & _
" <a href="/img/file2.jpg"><img src="/img/file2.jpg" /></a>" & @CRLF & _
"" & @CRLF & _
" <img src="/img/file3.jpg" />" & @CRLF & _
"" & @CRLF & _
""
Local $sSubst = "<a href="$1">$0</a>"
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