I need to determine whether a phone number is valid before attempting to dial it. The phone call can go anywhere in the world.
What regular expression will match valid international phone numbers?
I need to determine whether a phone number is valid before attempting to dial it. The phone call can go anywhere in the world.
What regular expression will match valid international phone numbers?
I have used this below:
The format +CCC.NNNNNNNNNNxEEEE or 00CCC.NNNNNNNNNNxEEEE
Phone number must start with '+' or '00' for an international call. where C is the 1–3 digit country code,
N is up to 14 digits,
and E is the (optional) extension.
The leading plus sign and the dot following the country code are required. The literal “x” character is required only if an extension is provided.
This will work for international numbers;
C#:
JS:
I use this one:
Advantages: recognizes + or 011 beginnings, lets it be as long as needed, and handles many extension conventions. (#,x,ext,extension)
Here's an "optimized" version of your regex:
You can replace the
\d
s with[0-9]
if your regex syntax doesn't support\d
.Try this, I do not know if there is any phone number longer than 12: