#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)<img.+?class=["'].*?hero-class.*?["'].*?src=["'](.+?)["'].*?>"
Local $sString = "// it should match but it didn't" & @CRLF & _
"<img src="image.jpg" class="hero-class">" & @CRLF & _
"" & @CRLF & _
"// it shouldn't match class 'nohero-class-dont-match'" & @CRLF & _
"<img class="nohero-class-dont-match" src="image.jpg">" & @CRLF & _
"" & @CRLF & _
"// it shouldn't match custom tag 'imgs-tag'" & @CRLF & _
"<imgs-tag class="hero-class" src="image.jpg">" & @CRLF & _
"" & @CRLF & _
"// it shouldn't match two tags and text between them" & @CRLF & _
"<img src="foo.jpg" class="hero-class"> any text <img src="image.jpg">" & @CRLF & _
"" & @CRLF & _
"// it should match whole src attribute, not just part" & @CRLF & _
"<img class="hero-class" src="mcdonald's.jpg">" & @CRLF & _
"" & @CRLF & _
"// it shouldn't match custom attribute 'data-src'" & @CRLF & _
"<img class="hero-class" data-src="custom info" src="image.jpg">" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
""
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