Saturday, 23 July 2011

Regular expression: color hex code

It will match the short 3 digit form for the 216 Web safe colors and the full 6 digit form too.

^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$