#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?x)<img\s+" & @CRLF & _
"(?=[^>]*\balt="(?<alt>[^>]*?)")? # optional alt attribute" & @CRLF & _
"(?=[^>]*\bclass="(?<class>[^>]*?)")? # optional class attribute" & @CRLF & _
"(?=[^>]*\bsrc="(?<src>[^>]*?)") # src attribute" & @CRLF & _
"[^>]*\/>"
Local $sString = "<img src="image.png" alt="test" style="zoom:55%;" />" & @CRLF & _
"<img class="big" src="image2.png" />" & @CRLF & _
"<img alt="test" src="image.png" style="zoom:55%;" />" & @CRLF & _
"<img src="image.png" class="small" style="zoom:55%;" alt="test" />" & @CRLF & _
"<img src="image.png" alt="test" style="zoom:55%;" />" & @CRLF & _
"<img src="image.png"" & @CRLF & _
" alt="test"" & @CRLF & _
" style="zoom:55%;" />"
Local $sSubst = "{.${class}}"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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