T
ToolPrime

Regex for Phone Number (US)

Validates US phone numbers in various formats: (555) 123-4567, 555-123-4567, 5551234567.

Pattern

/^\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/

Live Tester

Enter a string to test

Examples

(555) 123-4567
555-123-4567
5551234567
(055) 123-4567
123-4567
555-1234-567

Pattern Breakdown

^\(?[2-9]\d{2}\)? — area code with optional parentheses

[-.\s]? — optional separator

\d{3} — exchange code (3 digits)

[-.\s]?\d{4}$ — separator + subscriber number (4 digits)

Code Snippets

Javascript

const regex = /^\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/;
regex.test("(555) 123-4567"); // true

Python

import re
pattern = r"^\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4}$"
bool(re.match(pattern, "(555) 123-4567"))  # True

Php

$pattern = '/^\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/';
preg_match($pattern, "(555) 123-4567"); // 1

Related Patterns

Frequently Asked Questions

What is the regex for Phone Number (US)?
The regex pattern for Phone Number (US) is /^\(?[2-9]\d{2}\)?[-.\s]?\d{3}[-.\s]?\d{4}$/. Validates US phone numbers in various formats: (555) 123-4567, 555-123-4567, 5551234567.
How do I use the Phone Number (US) regex in JavaScript?
In JavaScript you create the pattern with a regex literal or the RegExp constructor and call .test() to check a string against it. A ready-to-copy example is shown in the Code Snippets section above, alongside Python and PHP versions.
What does the Phone Number (US) pattern match?
It matches strings like (555) 123-4567; it rejects strings like (055) 123-4567. See the Examples section above for the full list of matching and non-matching cases.

Related Tools