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.
Need a syntax reminder? Read our detailed guide on the Hex Color Finder Regex Pattern.
//
#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
How to Solve this Regex Challenge
To complete the Hex Color Finder challenge, you must write a regular expression pattern that satisfies all specified test cases.
Steps to Complete:
- Analyze the Requirements: Read the description and review the list of test cases below. Identify which strings must be matched (green markers) and which must be rejected (red markers).
- Draft Your Pattern: Enter your regex in the interactive editor. Use the provided Hint button if you get stuck.
- Verify: The test cases panel will update in real-time as you type, showing which strings match your current expression.
- Review the Solution: Once you successfully pass all test cases, review the explanation to understand the logic behind the solution.