US Phone Number Validation Regex (Standard Format)
• CronOS Team
regexphonevalidationtutorialus-phone
Need to generate a regex pattern?
Use CronOS to generate any regex pattern you wish with natural language. Simply describe what you need, and we'll create the perfect regex pattern for you. It's completely free!
US Phone Number Validation Regex (Standard Format)
Learn how to validate US phone numbers in standard formats with optional parentheses, dashes, dots, and spaces using regex.
Pattern Breakdown
regex
^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$
Components
| Component | Description | Matches |
|---|---|---|
^ | Start anchor | Ensures match from string start |
\(? | Optional opening parenthesis | Optional ( character |
\d{3} | Area code | Exactly 3 digits |
\)? | Optional closing parenthesis | Optional ) character |
[-.\s]? | Optional separator | Optional dash, dot, or space |
\d{3} | Exchange code | Exactly 3 digits |
[-.\s]? | Optional separator | Optional dash, dot, or space |
\d{4} | Subscriber number | Exactly 4 digits |
$ | End anchor | Ensures match to string end |
Character Classes
\(- Literal opening parenthesis (escaped)\)- Literal closing parenthesis (escaped)\d- Any digit (0-9)[-.\s]- Character class: dash, dot, or whitespace?- Quantifier: zero or one occurrence (optional){3}- Quantifier: exactly 3 occurrences{4}- Quantifier: exactly 4 occurrences
Examples
Valid:
(555) 123-4567555-123-4567555.123.45675551234567(555)123-4567555 123 4567(555) 123.4567
Invalid:
555-123-456(missing last digit)(555-123-4567(mismatched parentheses)55-123-4567(area code too short)555-12-4567(exchange code too short)555-123-45678(subscriber number too long)+1-555-123-4567(country code not supported)
Implementation
JavaScript
javascript
const phoneRegex = /^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/;
phoneRegex.test('(555) 123-4567'); // true
phoneRegex.test('555-123-4567'); // true
phoneRegex.test('5551234567'); // true
phoneRegex.test('555-123-456'); // false (too short)
Python
python
import re
phone_regex = r'^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$'
bool(re.match(phone_regex, '(555) 123-4567')) # True
bool(re.match(phone_regex, '555-123-4567')) # True
bool(re.match(phone_regex, '5551234567')) # True
Go
go
phoneRegex := regexp.MustCompile(`^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$`)
phoneRegex.MatchString("(555) 123-4567") // true
phoneRegex.MatchString("555-123-4567") // true
phoneRegex.MatchString("5551234567") // true
Limitations
- No country code: Doesn't support
+1prefix - Mismatched parentheses: Allows
(555-123-4567(opening without closing) - No extension support: Doesn't handle extensions like
x1234 - No validation of area codes: Accepts invalid area codes like
000 - Mixed separators: Allows mixed formats like
(555) 123.4567
When to Use
- US phone number input forms
- Client-side validation for common US formats
- When you want to accept multiple formatting styles
- Quick format checking
For production, consider:
- Adding country code support:
^(\+1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$ - Validating area codes against known valid ranges
- Normalizing phone numbers before storage
- Server-side validation
Need to generate a regex pattern?
Use CronOS to generate any regex pattern you wish with natural language. Simply describe what you need, and we'll create the perfect regex pattern for you. It's completely free!