#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?<rgb>rgb\((?<red>\d{1,3}),\s*\d{1,3},\s*\d{1,3}\))$|^(?<rgba>rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*[01](\.\d{1,2})?\))$|^(?<hsla>hsla\(\d{1,3},\s*\d{1,3}%,\s*\d{1,3}%,\s*[01](\.\d{1,2})?\))$|^(?<hsl>hsl\(\d{1,3},\s*\d{1,3}%,\s*\d{1,3}%\))$|^(?<hex>#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})(\d{2})?)$|^(?<cmyk>cmyk\(\d{1,3}%,\s*\d{1,3}%,\s*\d{1,3}%,\s*\d{1,3}%\))$"
Local $sString = "rgb(255,255,255)" & @CRLF & _
"rgb(1,23,255)" & @CRLF & _
"rgb(132,21,35)" & @CRLF & _
"rgba(255,255,255,0.4)" & @CRLF & _
"rgba(1,23,255,0.3)" & @CRLF & _
"rgba(1,23,255,1)" & @CRLF & _
"rgba(1,23,255,1.0)" & @CRLF & _
"rgba(132,21,35,0.7)" & @CRLF & _
"#403238" & @CRLF & _
"#ff323890" & @CRLF & _
"#ff890" & @CRLF & _
"#FF323890" & @CRLF & _
"hsl(240, 100%, 50%)" & @CRLF & _
"hsl(248, 53%, 58%)" & @CRLF & _
"hsl(147, 50%, 47%)" & @CRLF & _
"hsla(9, 100%, 64%, 0.6)" & @CRLF & _
"hsla(9, 100%, 64%, 0.8)" & @CRLF & _
"hsla(9, 100%, 64%, 0.8)" & @CRLF & _
"cmyk(0%, 100%, 100%, 0%)" & @CRLF & _
"cmyk(0%,46%,51%,37%)" & @CRLF & _
"" & @CRLF & _
"// should fail" & @CRLF & _
"rgba(255,255,255)" & @CRLF & _
"rgba(1,23,255)" & @CRLF & _
"rgba(132,21,35)" & @CRLF & _
"rgba(1,23,255,0.)" & @CRLF & _
"hsla(240, 100%, 50%)" & @CRLF & _
"hsla(248, 53%, 58%)" & @CRLF & _
"hsla(147, 50%, 47%)" & @CRLF & _
"rgb(255,255,255,0.4)" & @CRLF & _
"rgb(1,23,255,0.13)" & @CRLF & _
"rgb(132,21,35,0.14)" & @CRLF & _
"hsl(9, 100%, 64%, 0.6)" & @CRLF & _
"hsl(9, 100%, 64%, 0.8)" & @CRLF & _
"hsl(9, 100%, 64%, 0.8)" & @CRLF & _
"#FG323890" & @CRLF & _
"#ars90" & @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