#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)(<[^>]*class=("|'))(\b(foo)(\w|\-)*)*"
Local $sString = "<body>" & @CRLF & _
" <div style="margin-left:6px;" class="foo-pink blfoo-pin-foo-kue red yellow bar-green -moz-FF foo-pink moz-FF foo-pink" >" & @CRLF & _
" <fieldset class="foo customClass foo clFieldsBar bar-try" id="idField foo- bar-dfgdgdfg"> " & @CRLF & _
" <legend><span>Qu'en pensez-vous ?</span></legend>" & @CRLF & _
" < id="idText" class='foo- Comment_text fdgdgdfg -foo-ddede mso-whitespace' name="nameText barName"></textarea> bar-deded foo-green" & @CRLF & _
" </fieldset>" & @CRLF & _
" class="blue dffsf sdf mso-green foo"" & @CRLF & _
" </div> " & @CRLF & _
"</body>"
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