Regex for phone numbers

8 Mar 2026

Phone numbers in the US and Canada consist of ten digits: a three-digit area code, a three-digit central office code, and a four-digit line number. These components may be separated by dashes, spaces, or dots; the area code is often written in parentheses:

619-555-0167
(619) 555-0167
619.555.0167

There are some limits on the area code:

Taking these restrictions into account, we can put together this regular expression to match a 10-digit US phone number:

^[ \t]*\(?(?!988)[2-9](?!11)\d\d\)?[ .-]?\d{3}[ .-]?\d{4}[ \t]*$

We use a negative lookahead here to skip the N11 codes and 988, so this regex is a bit more fool-proof than other solutions floating on the Internet. For example, it won't match 123-456-7890 or 911-123-4567.

The [ \t]* part skips optional whitespace before or after the phone number. The regex starts with ^ and ends with $, so it will match the whole string or a line (in multi-line mode). If you want to find phone numbers in the text rather than verify that the string is a phone number, please use \b to match word boundaries:

\b\(?(?!988)[2-9](?!11)\d\d\)?[ .-]?\d{3}[ .-]?\d{4}\b

Another useful addition to this regex is allowing the initial +1 or 1 for long-distance calling:

^[ \t]*(?:\+1 ?|1 ?)?\(?(?!988)[2-9](?!11)\d\d\)?[ .-]?\d{3}[ .-]?\d{4}[ \t]*$

Now the regex also matches:

+1 619-555-0167
+16195550167
1 619-555-0167
Regex for US phone numbers

International phone numbers consist of a plus sign, a country code (1 to 3 digits), and the national phone number. The total phone number length is limited to a maximum of 15 digits. The minimum length is not specified in the standard, but I found Niue, an island country with a three-digit country code and four-digit national numbers. Five digits are more common, see Tokelau, Tonga, Solomon Islands, or Vanuatu. This gives us the following regex:

^[ \t]*\+(?:\d\)?[ .-]?\(?){6,14}\d[ \t]*$

We first match the plus sign, then a digit. After each digit, there can be a closing parenthesis, then a space, dot, or dash, then an opening parenthesis. The last digit is matched separately; the total number of digits is from 7 to 15.

Restricting the phone number length for each country would be complicated and the numbering plans change sometimes, so I recommend allowing some freedom here.

The regular expressions above also don't try to balance parentheses; for example, +1 (214 555-0198 would match, but this is rarely a problem.

Finally, if you want to match either an international phone number or a US/Canadian number, you can combine both regexes:

^[ \t]*(?:(?:\+|011 ?)(\d\)?[ .-]?\(?){6,14}\d|\(?(?!988)[2-9](?!11)\d\d\)?[ .-]?\d{3}[ .-]?\d{4})[ \t]*$

In this combined regex, we also allow international phone numbers to start with 011 instead of the plus.

Aba Search and Replace screenshot

Stop pasting your data into dubious cloud-based tools. Aba Search and Replace is your Swiss army knife for regular expression search, fast and safe updates across multiple files, and various conversions, with all your data staying on your computer. Built for power users, developers, testers, and analysts. Hand-coded in the EU.

This is a blog about Aba Search and Replace, a tool for replacing text in multiple files.