Phone numbers by country — tested regexes
Every country has its own numbering plan: country code, length, mobile prefixes, a leading zero that disappears in international format. Each page compares a fixed regex against real attempts found online, with their real score on a test corpus.
19 countries covered.
- Australian phone numberAustralian phone regex tested on 28 cases, incl. official ACMA numbers, compared to 3 real attempts: spaces and +61 cause trouble.
- Belgian phone numberBelgian phone regex tested on 33 cases, compared to 3 real attempts: sent.dm refuses 010 and 050, and +32 or separators cause trouble.
- Brazilian phone numberBrazilian phone regex tested on 26 cases, compared to 3 real attempts: nonexistent area codes (10, 20, 23...) and fake landlines pass almost everywhere.
- Canadian phone numberCanadian phone regex tested on 34 cases, incl. the NANP fictional 555-01xx numbers: US area codes (212...) are refused.
- Chinese phone numberChinese phone regex tested on 35 cases, compared to 3 real attempts: landlines without the 0, 2-digit area codes and separators cause trouble.
- Dutch phone numberDutch phone regex tested on 36 cases, compared to 3 real attempts: a 9-digit landline passes at sent.dm, 060 and 066 mobiles at jquery-validation.
- French phone numberFrench phone number regex tested on 22 real cases, compared against 3 patterns from Stack Overflow with each one's real score. Limits documented.
- German phone numberGerman phone regex tested on 35 cases, incl. the Bundesnetzagentur's official fictional numbers, compared to 3 real attempts: +49 is refused.
- Italian phone numberItalian phone regex tested on 33 cases, compared to 3 real attempts: the landline 0 is kept with +39, and two regexes accept almost anything.
- Japanese phone numberJapanese phone regex tested on 26 cases, compared to 3 real attempts: '010-...' and '030-...' pass, and '+81' is refused almost everywhere.
- Mexican phone numberMexican phone regex tested on 35 cases, compared to 3 real attempts: the old 01, 044 and 045 prefixes still pass.
- Norwegian phone numberNorwegian phone regex tested on 34 cases, compared to 3 real attempts: a comma inside a class, no +47, and a 1x or 5x landline unchecked.
- Polish phone numberPolish phone regex tested on 33 cases, compared to 3 real attempts: nonexistent prefixes (01, 40, 20...) and separators cause trouble.
- South African phone numberSouth African phone regex tested on 34 cases, compared to 3 real attempts: nonexistent prefixes (019, 020...) pass, and +27 is mishandled.
- Spanish phone numberSpanish phone regex tested on 24 cases, compared to 3 real attempts: '[6|7]' contains a literal pipe, and '000 000 000' passes almost everywhere.
- Swedish phone numberSwedish phone regex tested on 35 cases, compared to 3 real attempts: two of them refuse landlines (08, 031...), one refuses +46.
- Swiss phone numberSwiss phone regex tested on 33 cases, compared to 3 real attempts: separators, +41 or the 9-digit length are not checked.
- UK phone numberUK phone regex tested on 35 cases (incl. Ofcom's official drama numbers), compared to 3 real attempts: 08 and 09 numbers are rejected.
- US phone numberUS phone number regex tested on 20 real cases, compared to 3 attempts, one (411 votes) with mismatched parentheses. Limits included.