#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?i)(?P<Hex>(?<=.[^}{])#(?:[\dA-F]{6}|[\dA-F]{3})(?=\W[^}{]))+"
Local $sString = "#BED" & @CRLF & _
"{" & @CRLF & _
" color: #FfFdF8; background-color:#aef;" & @CRLF & _
" font-size: 123px;" & @CRLF & _
" background: -webkit-linear-gradient(top, #f9f9f9, #fff);" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"#Cab" & @CRLF & _
"{" & @CRLF & _
" background-color: #ABC;" & @CRLF & _
" border: 2px dashed #fff;" & @CRLF & _
"} " & @CRLF & _
"" & @CRLF & _
"#dddd" & @CRLF & _
"" & @CRLF & _
"Valid Hex Color Codes" & @CRLF & _
"#FFF " & @CRLF & _
"#025 " & @CRLF & _
"#F0A1FB " & @CRLF & _
"" & @CRLF & _
"Invalid Hex Color Codes" & @CRLF & _
"#fffabg" & @CRLF & _
"#abcf" & @CRLF & _
"#12365erff" & @CRLF & _
"" & @CRLF & _
"#BED{ color: #FfFdF8; background-color:#aef; font-size: 123px;}#Cab{ background-color: #ABC; border: 2px dashed #fff;}" & @CRLF & _
""
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