#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?xJi)(?(DEFINE)" & @CRLF & _
" (?<decimal>(?(int)([.][0-9]+)?|[.][0-9]+))" & @CRLF & _
" (?<percentage>" & @CRLF & _
" (100|" & @CRLF & _
" (?<int>([0-9]|[1-9][0-9]))? # Have integer be optional (0-100 only)" & @CRLF & _
" (?P>decimal) # Have decimal required when an integer is not included" & @CRLF & _
" )" & @CRLF & _
" (?<symbol>%)" & @CRLF & _
" )" & @CRLF & _
" (?<hue> " & @CRLF & _
" (?<int>36[0]|3[0-5][0-9]|[12][0-9][0-9]|[1-9]?[0-9])? # Have integer be optional" & @CRLF & _
" (?P>decimal) # Have decimal required when an integer is not included" & @CRLF & _
" (?<symbol>\s*deg\s*)?" & @CRLF & _
" )" & @CRLF & _
" (?<alpha>" & @CRLF & _
" (?(alpha),\s*(" & @CRLF & _
" 1[.]0|" & @CRLF & _
" (?<int>0)? # Have integer be optional" & @CRLF & _
" (?P>decimal) # Have decimal required when integer is not incldue" & @CRLF & _
" )\s*)" & @CRLF & _
" )" & @CRLF & _
" (?<hsl>\s*(?P>hue)\s*,\s*(?P>percentage)\s*,\s*(?P>percentage)\s*)" & @CRLF & _
")" & @CRLF & _
"hsl(?<alpha>a)?\((?P>hsl)(?P>alpha)\)"
Local $sString = "hsl(10, 50deg, 150%)" & @CRLF & _
"HSLA(50.35, .531, 10%)" & @CRLF & _
"HSLA(50.5deg, .531%, .9%, 1.0)"
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