EasyValidation
Phone Number Format Check
Write a regex that validates US-style phone numbers written strictly as three digits, a dash, three digits, a dash, then four digits (e.g. 123-456-7890).
Need a syntax reminder? Read our detailed guide on the Phone Number Format Check Regex Pattern.
//
123-456-7890 / 555-123-4567 / 12-456-7890 / 123.456.7890 / 1234567890
Test cases
- 123-456-7890expect match
- 555-123-4567expect match
- 12-456-7890expect no match
- 123.456.7890expect no match
- 1234567890expect no match
- 123-45-7890expect no match
How to Solve this Regex Challenge
To complete the Phone Number Format Check 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.