#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)^hsla?\((?:(-?\d+(?:deg|g?rad|turn)?),\s*((?:\d{1,2}|100)%),\s*((?:\d{1,2}|100)%)(?:,\s*((?:\d{1,2}|100)%|0(?:\.\d+)?|1))?|(-?\d+(?:deg|g?rad|turn)?)\s+((?:\d{1,2}|100)%)\s+((?:\d{1,2}|100)%)(?:\s+((?:\d{1,2}|100)%|0(?:\.\d+)?|1))?)\)$"
Local $sString = "hsl(123deg, 100%, 0%)" & @CRLF & _
"hsl(123, 100%, 0%)" & @CRLF & _
"hsl(123rad 100% 0%)" & @CRLF & _
"hsla(123grad, 100%, 0%, 0)" & @CRLF & _
"hsla(-123turn 100% 0% 1)" & @CRLF & _
"hsla(1 100% 0% 50%)" & @CRLF & _
"" & @CRLF & _
"bad ones" & @CRLF & _
" hsl(123deg, 100%, 0%)" & @CRLF & _
"hsl(123, 100%, 0%) " & @CRLF & _
"hsl(123ad 100% 0%)" & @CRLF & _
"hsla(123grd, 100%, 0%, 0)" & @CRLF & _
"hsla(-123trn 100% 0% 1)" & @CRLF & _
"hsla(1 a% 0% 50%)" & @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