#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?i)<a(.*?)href=('|\")([^\>]*).(jpe?g|png|gif|mp4|webp|bmp)('|\")(.*?)>"
Local $sString = "<a href="https://localhost/test" target="_blank">TEST</a>" & @CRLF & _
"" & @CRLF & _
"<a href="http://localhost/test.jpg" data-fancybox="fancybox" data-caption="">" & @CRLF & _
" <img src="https://localhost/test-400x400.jpg" alt="">" & @CRLF & _
"</a>" & @CRLF & _
"" & @CRLF & _
"<a href="https://localhost/te.2er44.-.awd.wd.ddwadst.jpg">" & @CRLF & _
" <img src="https://localhost/test-400x400.jpg" alt="">" & @CRLF & _
"</a>" & @CRLF & _
"" & @CRLF & _
"<a href="https://localhost/test.svg">" & @CRLF & _
" <img src="https://localhost/test-400x400.jpg" alt="">" & @CRLF & _
"</a>" & @CRLF & _
"" & @CRLF & _
"<a href="https://localhost/test.gif">" & @CRLF & _
" <img src="https://localhost/test-400x400.jpg" alt="">" & @CRLF & _
"</a>"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
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