#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?im)^#([A-F0-9]{3}){1,2}$"
Local $sString = "Only matches when there are 3 & 6 digits" & @CRLF & _
"#" & @CRLF & _
"#1" & @CRLF & _
"#12" & @CRLF & _
"#123" & @CRLF & _
"#1234" & @CRLF & _
"#12345" & @CRLF & _
"#123456" & @CRLF & _
"#1234567" & @CRLF & _
"Only matches if the letters used are: A, B, C, D, E & F" & @CRLF & _
"#ABCDEF" & @CRLF & _
"#BCDEFG" & @CRLF & _
"#0A1B2C" & @CRLF & _
"#0E1F2Z" & @CRLF & _
"Must use the 'i' flag to match lower & upper case." & @CRLF & _
"#AaBbCc" & @CRLF & _
"" & @CRLF & _
"Arbitrary examples" & @CRLF & _
"#15F" & @CRLF & _
"#C88" & @CRLF & _
"#9264FA" & @CRLF & _
"#fF0eE1" & @CRLF & _
"#FFFXFF" & @CRLF & _
"#FFFYFF" & @CRLF & _
"#ABCDEF" & @CRLF & _
"#ABC*EF" & @CRLF & _
"#778657" & @CRLF & _
"#E9B3C4"
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