/^/
EasyValidation

Hex Color Finder

Write a regex that matches valid hexadecimal color codes, either the short form (#fff) or the long form (#ffffff). The pattern must reject codes with the wrong number of digits or non-hex characters.

//
#fff #123abc #12345 #ffffff #zzzzzz #12AB56

Test cases

  • #fffexpect match
  • #FFFFFFexpect match
  • #123abcexpect match
  • #12345expect no match
  • #zzzzzzexpect no match
  • #ffexpect no match
  • 123abcexpect no match