#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?misx)<a" & @CRLF & _
"\s+" & @CRLF & _
"((?:[^\s<>'"=]+(?:=(?:"[^"]*"|'[^']*'|[^\s'">]+))?\s+)*)" & @CRLF & _
"href=(?|"([^"]*\.(?:jpe?g|png))"|'([^']*\.(?:jpe?g|png))'|([^\s'">]*\.(?:jpe?g|png))(?=[>\s]))" & @CRLF & _
"((?:\s+[^\s<>'"=]+(?:=(?:"[^"]*"|'[^']*'|[^\s'">]+))?)*)" & @CRLF & _
"\s*>" & @CRLF & _
"(.*?)" & @CRLF & _
"</a>"
Local $sString = "<p>С этой формы приходят заявки <a href="https://site.com/lack_tech.php">https://site.com/lack_tech.php</a></p>" & @CRLF & _
"<p>Или что ты имеешь ввиду?</p>" & @CRLF & _
"<div class="attachment_files_message"> " & @CRLF & _
" <p>Прикреплённые файлы:</p>" & @CRLF & _
" <a href="http://site.com/public/uploads/kylticket/2670/Screenshot_1.png" target="_blank">Screenshot_1.png</a>" & @CRLF & _
"<a href=http://site.com/public/uploads/kylticket/2670/Screenshot_1.png target="_blank">Screenshot_1.png</a>" & @CRLF & _
" <a" & @CRLF & _
" target="_blank"" & @CRLF & _
" href="http://site.com/public/uploads/kylticket/2670/Screenshot_1.png" >Screenshot_1.png</a>" & @CRLF & _
"</div>"
Local $sSubst = "<a $1$3 data-fancybox="gallery" href="$2"><img src="$2" alt="" class="tmp_class"></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