#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mUix)^(?:(?<!\/\/|\/\*|<!--).)* #check if commented out" & @CRLF & _
"<[a-z][a-z0-9]*?\b #find start of a tag" & @CRLF & _
"(?:.(?![^?]>))+ #Must not find > between start and class unless ?>" & @CRLF & _
"class=(["']) #Find class and opening quotes" & @CRLF & _
"(?:(?!\1).)* \bmatch\b (?:(?!\1).)* #see if our tag is in between the quotes" & @CRLF & _
"\1 #closing quotes" & @CRLF & _
".*(?<!\?)> #find first > without ? in front of it"
Local $sString = "<h1 class="match">Match list</h1>" & @CRLF & _
"" & @CRLF & _
"<p class="match">Simple class element.</p>" & @CRLF & _
"" & @CRLF & _
" <p></p> <h6 class='more match classes'> more classes different comma</h6>" & @CRLF & _
"" & @CRLF & _
" <fdf <?php echo 'data="extra data test to disturb the page."'; ?> class='incluEdit match classes' > dffd" & @CRLF & _
"" & @CRLF & _
" <div class='hoppa match more classes' <?=$zooi ?> > nested elements </div></div>" & @CRLF & _
"" & @CRLF & _
"// <h1 class='match more classes'> no Match list</h1>" & @CRLF & _
"/* <h1 class='match more classes'> no Match list</h1>" & @CRLF & _
"<!-- <h1 class='match more classes'> no Match list</h1>" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"<p class='nomatch more classes'>shouldn't match</p>"
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