US Phone Number
beginnerMatches US phone numbers in various common formats.
phonevalidationustelephone
Pattern
/(?:\+?1[-\s.]?)?\(?\d{3}\)?[-\s.]?\d{3}[-\s.]?\d{4}/gTry It
0 of 7 strings matched
Explanation
Matches US phone numbers with optional country code (+1), area code with optional parentheses, and groups separated by hyphens, spaces, or dots.
Test Strings
Matching
- (555) 123-4567
- +1-555-123-4567
- 555.123.4567
- 5551234567
Non-matching
- 123-456
- 555-1234-567
- abc-def-ghij
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:\+?1[-\s.]?)?\(?\d{3}\)?[-\s.]?\d{3}[-\s.]?\d{4}/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);Common Variations
Strict format
\(\d{3}\) \d{3}-\d{4}Only matches (555) 123-4567 format