In this example RGB value " 777,0,0 " witch is not a valid RGB value is also captured. How to avoid this?
If i remove the first 3 letters from the variable, value " 800000 " is not captured why ?
Code: Select all
var=
(
try
800000 777,0,0 kldjfdoifj 12,12,3 dfjiosjf jksdi
8000AA 128,0,0 125,125,125|255,254,253 0xffaabb
FF0000 256,0,0
FFA500 257,165,0
FFFF00 550,255,0
808000 128,128,0
008000 0,128,0
Color Name Hex Code
RGB Decimal Code
RGB
800080 128,0,128
FF00FF 255,0,255
00FF00 0,255,0
008080 0,128,128
00FFFF 0,255,255
0000FF 0,0,255
Name Hex Code
RGB Decimal Code
RGB
000080 0,0,128
000000 0,0,0
808080 128,128,128
C0C0C0 192,192,192
FFFFFF 255,255,255
)
colors:=[]
p:=0
while p:=RegExMatch(var, "[0-9a-fA-F]{6}|(\d{1,3}) ?, ?(\d{1,3}) ?, ?(\d{1,3})", color%a_index%, p+strlen("color" %a_index%))
{
colors.push(color%a_index%)
}
msgbox, % st_printarr(colors)
; (by tidbit)
st_printArr(array, depth=5, indentLevel="")
{
for k,v in Array
{
list.= indentLevel "[" k "]"
if (IsObject(v) && depth>1)
list.="`n" st_printArr(v, depth-1, indentLevel . " ")
Else
list.=" => " v
list.="`n"
}
return rtrim(list)
}