Regex Telephone Number Examples

Last Updated : Oct 11, 2023 |
Prolog information
The following are example regex strings for telephone number matching.
Purpose
Pattern
Description
Match any numeric telephone number
^\d+$
Match any dialing
^.+$
This differs from the above match for any numbers as it also includes +, * and # elements that may occur in telephone number.
^[0-9*#]$
This differs from the above match in that is only matches telephone numbers using the numeric digits, * and #.
Match any 7-digit number
^(\d{7})$
This would for example, match the dialing of a local number in the US. The number requires a transform to add the digits for national dialing with the local area code.
Match any 11-digit number beginning with a +1
^\+1(\d{10})$
This would for example, match the dialing of a national number within the US.
Match any 11-digit number beginning with 1555 or 1666
^\+1(555|666)(\d{7})$
This example would match the dialing of national numbers in the US with the area code 555 or 565.