#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?:#(?:[A-Fa-f0-9]{3}){1,2}|(?:rgb[(](?:\s*0*(?:\d\d?(?:\.\d+)?(?:\s*%)?|\.\d+\s*%|100(?:\.0*)?\s*%|(?:1\d\d|2[0-4]\d|25[0-5])(?:\.\d+)?)\s*(?:,(?![)])|(?=[)]))){3}|hsl[(]\s*0*(?:[12]?\d{1,2}|3(?:[0-5]\d|60))\s*(?:\s*,\s*0*(?:\d\d?(?:\.\d+)?\s*%|\.\d+\s*%|100(?:\.0*)?\s*%)){2}\s*|(?:rgba[(](?:\s*0*(?:\d\d?(?:\.\d+)?(?:\s*%)?|\.\d+\s*%|100(?:\.0*)?\s*%|(?:1\d\d|2[0-4]\d|25[0-5])(?:\.\d+)?)\s*,){3}|hsla[(]\s*0*(?:[12]?\d{1,2}|3(?:[0-5]\d|60))\s*(?:\s*,\s*0*(?:\d\d?(?:\.\d+)?\s*%|\.\d+\s*%|100(?:\.0*)?\s*%)){2}\s*,)\s*0*(?:\.\d+|1(?:\.0*)?)\s*)[)])$"
Local $sString = "#0F0F0F" & @CRLF & _
"#123" & @CRLF & _
"#1234" & @CRLF & _
"#ABC456" & @CRLF & _
"#1234567" & @CRLF & _
"rgb(1,2,3)" & @CRLF & _
"rgb(1,2,)" & @CRLF & _
"rgb(112233)" & @CRLF & _
"rgb(255,249,199)" & @CRLF & _
"rgb(256,249,199)" & @CRLF & _
"rgb(255,249,199,)" & @CRLF & _
"rgb( 100%, 199, 50%)" & @CRLF & _
"rgb( 100%, 199%, 50%)" & @CRLF & _
"rgb(1,2,3%,.5)" & @CRLF & _
"rgba(1,2,3%,0.75)" & @CRLF & _
"rgba(1,2,3%,.5)" & @CRLF & _
"rgba(1,2,.5)" & @CRLF & _
"rgba(1,2,3)" & @CRLF & _
"rgba(1,249,100,1)" & @CRLF & _
"rgba(1,249,100,1.0)" & @CRLF & _
"rgba(1,249,100,1.1)" & @CRLF & _
"rgba(255,256,255,1)" & @CRLF & _
"rgba(1,249.5,100%,1)" & @CRLF & _
"rgba(1,249.5,101%,1)" & @CRLF & _
"hsl(360,2%,100%)" & @CRLF & _
"hsl(361,2%,100%)" & @CRLF & _
"hsl(,2%,100%)" & @CRLF & _
"hsl(360,2%,)" & @CRLF & _
"hsl(360,2%,0100.00%)" & @CRLF & _
"hsl(360,2%,101%)" & @CRLF & _
"hsla(180,2%,100%,0.5)" & @CRLF & _
"hsla(180,2%,100%,)"
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