Matches 3 or 6 digit hex color codes.
/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/const regex = /^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/;
regex.test('#FFFFFF');import re
regex = re.compile(r'^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$')
bool(regex.match('#FFFFFF'))import "regexp"
matched, _ := regexp.MatchString(`^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$`, "#FFFFFF")use regex::Regex;
let re = Regex::new(r"^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$").unwrap();
re.is_match("#FFFFFF")