#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)(<[\s]*(?![\/])figure.*?>)|(([^<.*figure.*>\w])(<[\s]*(?![\/])img.*?>)([^<.*\/*figure.*>]))"
Local $sString = "аываыва <img sdasd asd > sdf dsf < sdf imG>" & @CRLF & _
"" & @CRLF & _
"<h2>" & @CRLF & _
"" & @CRLF & _
"< H2 sdf > </h2> sdf sdf sdf sdfsdf sdf sd f" & @CRLF & _
"" & @CRLF & _
"< sdf sdf H2 sdf > " & @CRLF & _
"" & @CRLF & _
"</h2>" & @CRLF & _
"< h2> adasd asd < h2> " & @CRLF & _
"< / H2>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<img 2>" & @CRLF & _
"" & @CRLF & _
"<figure><img></figure> ыва ыва ыва ыва ыва ыва" & @CRLF & _
"" & @CRLF & _
"< figure >< img >< / figure >" & @CRLF & _
"" & @CRLF & _
"< figure sdfsdfsdfsd f> asd as das asd< img asd asd a/> asd asd asd <> < / figure> фываы ва ыв" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<img>" & @CRLF & _
"" & @CRLF & _
"< figure > фыв ыфв фыв фыв ыфв < img > < / figure >" & @CRLF & _
"" & @CRLF & _
"<figure itemprop="associatedMedia image" itemscope="" itemtype="https://schema.org/ImageObject"> <meta itemprop="representativeOfPage" content="true"> <img itemprop="contentUrl url" src="//site.com/url.jpg" title="" alt=""> <meta itemprop="name" content=""> <meta itemprop="width" content=""> <meta itemprop="height" content=""></figure>"
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