You need to put /
Use any of
str.match(/[A-Fa-f0-9]{6}/)
or
str.match(/[a-f0-9]{6}/i)
instead of str.match([A-Fa-f0-9]{6})
Now if your string may contain multiple HEX codes then use the following instead:
str.match(/[a-f0-9]{6}/gi)
-> This will fetch an array of all such HEX codes and hence you can access each such instance using index to the array as follows:
str="Can I have 00fA00 and B0fA0c please?"
hex_codes=str.match(/[a-f0-9]{6}/gi);
//hex_codes[0]=="00fA00" and hex_codes[1]=="B0fA0c"
Here is the fiddle demo