#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)#(?:[0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})(?=;|[^(]*\))"
Local $sString = "#BED, #foo" & @CRLF & _
"{" & @CRLF & _
" color: #FfFdF8; background-color:#aef;" & @CRLF & _
" font-size: 123px;" & @CRLF & _
" background: -webkit-linear-gradient(top, #f9f9f9, #fff);" & @CRLF & _
"}" & @CRLF & _
"#Cab" & @CRLF & _
"{" & @CRLF & _
" background-color: #ABC;" & @CRLF & _
" border: 2px dashed #fff;" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"#BED, p {" & @CRLF & _
" color: #ABC;" & @CRLF & _
" @media( min-width: 420px) {" & @CRLF & _
" color: #ABC;" & @CRLF & _
" }" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"#BED { background: url(http:xyz.com)}" & @CRLF & _
"" & @CRLF & _
"#BED { background: url(http:xyz.com) color: #ABC; }"
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