#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?<=\,|\+|\~|\>|\(|\)|\[|\]|\{|\}|^)(?<s>\s*)(?<tag>a|div|p|span|img|button)(?!\s*\[[^\]]*__canvas[^\]]*\])(?=[\:\,\+\~\>\(\)\[\]\{\}\s]+)(?=[^\}\;]*[\{])"
Local $sString = "@media only screen and (max-width: 600px) {" & @CRLF & _
" div>a[__canvas]:hover,a,div {" & @CRLF & _
" background-color: lightblue;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" i+img>audio,table:not(a+p)," & @CRLF & _
" button~.a " & @CRLF & _
" , " & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" span{" & @CRLF & _
" background-color: lightblue;" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"a {" & @CRLF & _
" background: url(http://a.b.com);" & @CRLF & _
" font-family: cursive, a, serif;" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"img" & @CRLF & _
" " & @CRLF & _
" " & @CRLF & _
" {" & @CRLF & _
" color: a;" & @CRLF & _
" font-family: a, serif;" & @CRLF & _
"}"
Local $sSubst = "${s}${tag}[__canvas]"
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