Regex to Match International Phone Numbers
Validate international phone numbers with country codes using this regex pattern. Matches formats like +44 20 7946 0958. Free online regex tool.
Regular Expression
/^\+?\d{1,3}[\s.-]?\(?\d{1,4}\)?[\s.-]?\d{1,4}[\s.-]?\d{1,9}$/
Token Breakdown
| Token | Description |
|---|---|
| ^ | Anchors at the start of the string (or line in multiline mode) |
| \+ | Matches a literal plus sign |
| ? | Makes the preceding element optional (zero or one times) |
| \d | Matches any digit (0-9) |
| {1,3} | Matches between 1 and 3 times |
| [\s.-] | Character class — matches any one of: \s.- |
| ? | Makes the preceding element optional (zero or one times) |
| \( | Matches a literal opening parenthesis |
| ? | Makes the preceding element optional (zero or one times) |
| \d | Matches any digit (0-9) |
| {1,4} | Matches between 1 and 4 times |
| \) | Matches a literal closing parenthesis |
| ? | Makes the preceding element optional (zero or one times) |
| [\s.-] | Character class — matches any one of: \s.- |
| ? | Makes the preceding element optional (zero or one times) |
| \d | Matches any digit (0-9) |
| {1,4} | Matches between 1 and 4 times |
| [\s.-] | Character class — matches any one of: \s.- |
| ? | Makes the preceding element optional (zero or one times) |
| \d | Matches any digit (0-9) |
| {1,9} | Matches between 1 and 9 times |
| $ | Anchors at the end of the string (or line in multiline mode) |
Detailed Explanation
This regex validates international phone numbers in various formats. Here is the token-by-token breakdown:
^ — Anchors the match at the start of the string.
+? — Matches an optional plus sign at the beginning, commonly used before the country code in international dialing format.
\d{1,3} — Matches one to three digits for the country code. Country codes range from one digit (e.g., 1 for US) to three digits (e.g., 358 for Finland).
[\s.-]? — Matches an optional separator (whitespace, dot, or hyphen) after the country code.
(? — Matches an optional opening parenthesis, as some formats enclose the area code in parentheses.
\d{1,4} — Matches one to four digits for the area or city code. Different countries have varying area code lengths.
)? — Matches an optional closing parenthesis.
[\s.-]? — Matches an optional separator.
\d{1,4} — Matches one to four digits for the next part of the phone number.
[\s.-]? — Matches another optional separator.
\d{1,9} — Matches one to nine digits for the remaining part of the number. This generous range accommodates the varying lengths of phone numbers across different countries.
$ — Anchors the match at the end.
International phone numbers vary greatly in length and format. This pattern is intentionally flexible to accommodate numbers from different countries. For strict validation of a specific country, a country-specific pattern is recommended.
Example Test Strings
| Input | Expected |
|---|---|
| +44 20 7946 0958 | Match |
| +1 (555) 123-4567 | Match |
| +81 3-1234-5678 | Match |
| ++1234 | No Match |
| +91 9876 543210 | Match |
Try It — Interactive Tester
60 charsFlags: noneMatches: 0Ctrl+Shift+C to copy regex
Related Regex Patterns
Regex to Match US Phone Numbers
/^(?:\+1\s?)?(?:\(?\d{3}\)?[\s.-]?)?\d{3}[\s.-]?\d{4}$/
Regex to Match Credit Card Numbers
/^(?:4\d{3}|5[1-5]\d{2}|3[47]\d{2}|6(?:011|5\d{2}))[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{1,4}$/
Regex to Match Social Security Numbers
/^(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}$/
Regex to Match US Zip Codes
/^\d{5}(?:-\d{4})?$/