Regex pattern
Phone Number Regex — free online tester
Match US / Canada phone numbers in every common written format — with or without country code.
The pattern
\+?1?[\s.-]?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}/gHow it works
Phone numbers are written so many different ways: (555) 123-4567, 555-123-4567, 555.123.4567, 5551234567, +1 (555) 123-4567. This pattern accepts all of them: an optional country code, an optional parenthesised area code, and three groups of digits separated by spaces, dashes, dots, or nothing.
When to use it
- ▸Extract phone numbers from CSV / spreadsheet imports
- ▸Find contact numbers in scraped pages
- ▸Validate North-American phone form fields
- ▸Clean up customer-support tickets
Tip
For international numbers, replace the 3-3-4 digit pattern with a more permissive `\d[\d\s().-]{6,20}\d` and post-validate with libphonenumber.
Try it on this input
Reach us at (555) 123-4567 during business hours. Sales: 555-123-4567 Support: 555.123.4567 Direct: 5551234567 With country code: +1 555 123 4567 or +1-555-123-4567 Not a phone: 123, 12-34, abc, random text
What this pattern doesn't catch
- ⚠Matches only North American (NANP) numbers — doesn't accept other country codes
- ⚠Doesn't validate that the area code or prefix is actually assigned
- ⚠Will match phone-like substrings inside longer numbers (e.g. credit cards) — anchor with \b for stricter use
More regex patterns
Email Regex
A practical email-validation regex that catches the 99% case without choking on every RFC edge case.
URL Regex
Extract every http(s) URL from a block of text — captures protocol, domain, path, query string, and fragment.
Date Regex (ISO 8601)
Match ISO 8601 dates (YYYY-MM-DD) and optionally times in any text — the format JSON APIs, databases, and logs use.
IPv4 Regex
Strictly match IPv4 addresses — rejects out-of-range octets like 256.0.0.1 that simpler patterns let through.
UUID Regex
Strict UUID pattern — validates version (1–7) and variant nibbles so random hex strings don't pass.
Credit Card Regex
Match credit-card numbers from major networks (Visa, Mastercard, Amex, Discover) for extraction or redaction.
Full Regex Tester →
Cheatsheet · pattern builder · cross-language translation · replace · explain · history
