100% Client-Side β’ 0 B Data Leaves Browser
formatting
US Phone Number Format Regex
Validates 10-digit North American telephone numbers in formats like (123) 456-7890 or 123-456-7890.
Regular Expression Pattern:
/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/
Valid Match Example:
(555) 234-5678
Invalid / Non-Match Example:
12345
Regex Syntax Breakdown & Explanation
- β’^\(?([0-9]{3})\)? : 3-digit area code with optional parentheses
- β’[-. ]? : Optional delimiter (hyphen, period, or space)
- β’([0-9]{3}) : 3-digit exchange code
- β’([0-9]{4})$ : 4-digit subscriber line number
Implementation in Popular Languages
JavaScript / TypeScript
const regex = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
const isValid = regex.test("(555) 234-5678");
console.log(isValid); // truePython (re)
import re
pattern = r"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$"
match = re.match(pattern, "(555) 234-5678")
print(bool(match)) # TrueGo (regexp)
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$`)
fmt.Println(re.MatchString("(555) 234-5678"))
}Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
The regular expression pattern is /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/. Validates 10-digit North American telephone numbers in formats like (123) 456-7890 or 123-456-7890.