Phone Number
identity.person.phone_numberTelephone number in various formats. Locale-specific due to digit grouping, area code positions, and formatting conventions (e.g., US +1 (xxx) xxx-xxxx vs EU +xx-xxx-xxx-xxxx). May include country code, area code, and extension.
Worked samples
DuckDB 1.5.5 · finetype 0.6.64
| Value | As VARCHAR | area_code | country_code | digits_only |
|---|---|---|---|---|
| +1 (555) 123-4567 | +1 (555) 123-4567 | 555 | 1 | 15551234567 |
| 555-123-4567 | 555-123-4567 | 555 | 5551234567 | |
| +44 20 7946 0958 | +44 20 7946 0958 | 44 | 442079460958 | |
| +33 1 42 68 53 00 | +33 1 42 68 53 00 | 33 | 33142685300 | |
| 07911 123456 | 07911 123456 | 07911123456 |
| AR | ^(\+?966[\s\-./\u2013]*)?0?[1-9]\d{1,2}([\s\-./\u2013]*\d{1,4}){2,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| AT | ^(\+?43[\s\-./\u2013]*(\(0\))?)?0?\d{1,4}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| BE | ^(\+?32[\s\-./\u2013]*(\(0\))?)?0?\d{1,3}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| CH | ^(\+?41[\s\-./\u2013]*(\(0\))?)?0?\d{2}([\s\-./\u2013]*\d{3}){1}([\s\-./\u2013]*\d{2}){2}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| CZ | ^(\+?420[\s\-./\u2013]*)?\d{3}([\s\-./\u2013]*\d{3}){2}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| DE | ^(\+?49[\s\-./\u2013]*(\(0\))?)?0?\d{2,5}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| DK | ^(\+?45[\s\-./\u2013]*)?\d{2}([\s\-./\u2013]*\d{2}){3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| EN_AU | ^(\+?61[\s\-./\u2013]*(\(0\))?)?\(?0?\d{1,4}\)?([\s\-./\u2013]*\d{1,4}){2,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| EN_CA | ^(\+?1[\s\-./\u2013]*)?\(?\d{3}\)?[\s\-./\u2013]*\d{3}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| EN_GB | ^(\+?44[\s\-./\u2013]*(\(0\))?)?0?\d{2,5}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| EN_US | ^(\+?1[\s\-./\u2013]*)?\(?\d{3}\)?[\s\-./\u2013]*\d{3}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| ES | ^(\+?34[\s\-./\u2013]*)?[5-9]\d{2}([\s\-./\u2013]*\d{2}){3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| ES_AR | ^(\+?54[\s\-./\u2013]*)?0?\(?\d{2,4}\)?[\s\-./\u2013]*\d{3,4}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| ES_CL | ^(\+?56[\s\-./\u2013]*)?\d([\s\-./\u2013]*\d{4}){2}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| ES_CO | ^(\+?57[\s\-./\u2013]*)?\d{3}([\s\-./\u2013]*\d{3}){1}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| ES_MX | ^(\+?52[\s\-./\u2013]*)?\(?\d{2,3}\)?[\s\-./\u2013]*\d{3,4}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| ES_PE | ^(\+?51[\s\-./\u2013]*)?\d{3}([\s\-./\u2013]*\d{3}){2}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| FI | ^(\+?358[\s\-./\u2013]*(\(0\))?)?0?\d{1,3}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| FR | ^(\+?33[\s\-./\u2013]*(\(0\))?)?0?[1-9]([\s\-./\u2013]*\d{2}){4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| GR | ^(\+?30[\s\-./\u2013]*)?\d{3}([\s\-./\u2013]*\d{3}){1}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| HI | ^(\+?91[\s\-./\u2013]*)?0?\d{5}[\s\-./\u2013]*\d{5}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| HU | ^(\+?36[\s\-./\u2013]*)?\(?\d{1,2}\)?([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| ID | ^(\+?62[\s\-./\u2013]*)?0?\d{2,4}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| IE | ^(\+?353[\s\-./\u2013]*(\(0\))?)?0?\d{1,2}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| IL | ^(\+?972[\s\-./\u2013]*)?0?\d{1,2}([\s\-./\u2013]*\d{3}){1}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| IT | ^(\+?39[\s\-./\u2013]*)?0?\d{1,4}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| JA | ^(\+?81[\s\-./\u2013]*)?0?\d{1,4}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| KO | ^(\+?82[\s\-./\u2013]*)?0?\d{1,3}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| MY | ^(\+?60[\s\-./\u2013]*)?0?\d{1,2}([\s\-./\u2013]*\d{1,4}){2,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| NG | ^(\+?234[\s\-./\u2013]*)?0?\d{3}([\s\-./\u2013]*\d{3}){1}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| NL | ^(\+?31[\s\-./\u2013]*)?0?\d{1,3}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| NO | ^(\+?47[\s\-./\u2013]*)?\d{2}([\s\-./\u2013]*\d{2}){3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| NZ | ^(\+?64[\s\-./\u2013]*(\(0\))?)?0?\d{1,2}([\s\-./\u2013]*\d{1,4}){2,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| PH | ^(\+?63[\s\-./\u2013]*)?0?\d{3}([\s\-./\u2013]*\d{3}){1}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| PL | ^(\+?48[\s\-./\u2013]*)?\d{3}([\s\-./\u2013]*\d{3}){2}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| PT | ^(\+?351[\s\-./\u2013]*)?\d{3}([\s\-./\u2013]*\d{3}){2}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| PT_BR | ^(\+?55[\s\-./\u2013]*)?\(?\d{2}\)?[\s\-./\u2013]*\d{4,5}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| RO | ^(\+?40[\s\-./\u2013]*)?0?\d{2,3}([\s\-./\u2013]*\d{3}){2}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| RU | ^(\+?7[\s\-./\u2013]*|8[\s\-./\u2013]*)?\(?\d{3}\)?([\s\-./\u2013]*\d{2,3}){3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| SE | ^(\+?46[\s\-./\u2013]*(\(0\))?)?0?\d{1,3}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| SG | ^(\+?65[\s\-./\u2013]*)?[3689]\d{3}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| TH | ^(\+?66[\s\-./\u2013]*)?0?\d{2}([\s\-./\u2013]*\d{3}){1}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| TR | ^(\+?90[\s\-./\u2013]*)?0?\d{3}([\s\-./\u2013]*\d{3}){1}[\s\-./\u2013]*\d{4}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| TW | ^(\+?886[\s\-./\u2013]*)?0?\d([\s\-./\u2013]*\d{4}){2}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| ZA | ^(\+?27[\s\-./\u2013]*(\(0\))?)?0?\d{2}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
| ZH | ^(\+?86[\s\-./\u2013]*)?0?\d{2,4}([\s\-./\u2013]*\d{1,8}){1,3}(\s*(ext\.?|Ext\.?|x|#)\s*\d{1,5})?(\s*(Work|Cell|Fax|Home|Office))?$ |
Shape
Length 7 to 30 characters.
^[+]?[0-9\s()\-\./\u2013]+([\s]*(ext\.?|Ext\.?|x|#)[\s]*\d{1,5})?([\s]*(Work|Cell|Fax|Home|Office))?$| Value | Length | Shape |
|---|---|---|
| +1 (555) 123-4567 | 17 | matches |
| 555-123-4567 | 12 | matches |
| +44 20 7946 0958 | 16 | matches |
| +33 1 42 68 53 00 | 17 | matches |
| 07911 123456 | 12 | matches |
| +1_(555) 123-4567 | 17 | rejected: separator swapped |
Told apart
Going the other way, this type's own rule accepts 1 of 4 samples of Gender Code and 5 of 5 samples of Phone Number (E.164).
Decompose extracts country code, area code, and digits-only version.
Background
Origin
The numbering plan behind phone numbers worldwide is ITU-T Recommendation E.164, titled The international public telecommunication numbering plan.[1] The first issue of E.164 was published in 1988 in Blue Book Fascicle II.2.[2] E.164 numbers are limited to digits only, with a maximum of fifteen digits.[2] E.164 divides the digit string into a country code of one to three digits, followed by the subscriber number.[2]
How a number is written down is a separate ITU-T Recommendation, E.123, titled Notation for national and international telephone numbers, e-mail addresses and web addresses.[3] The edition of E.123 in force is dated February 2001, and it superseded an edition of November 1988.[3] E.123 defines the plus sign as the international prefix symbol, written before the country code.[4] In international notation, E.123 says only spaces should be used to separate groups of digits.[4] E.123 uses parentheses in national notation to mark digits that are sometimes not dialled, such as an area code.[4] Parentheses are not allowed in E.123's international notation.[4]
Use
RFC 3966, which defines the tel URI, allows phone numbers to contain visual separators.[5] RFC 3966 says visual separators merely aid readability and are not used for URI comparison or placing a call.[5] In RFC 3966, globally unique numbers are identified by the leading + character.[5] RFC 3966 identifies phone extensions with an extension parameter.[5] Strip the separators and keep the digits, the leading plus and any extension apart before comparing or deduplicating numbers. (Meridian's view)
A number without a country code cannot be made international safely unless you know which country the record belongs to, so carry that context alongside the column. (Meridian's view) Google's libphonenumber is a common Java, C++ and JavaScript library for parsing, formatting and validating international phone numbers.[6] libphonenumber formats the Swiss number 044 668 18 00 as +41 44 668 18 00 in international form and +41446681800 in E.164 form.[6] libphonenumber's isPossibleNumber check uses only length information, while isValidNumber uses length and prefix information for a region.[6] A pattern match only shows that a value looks like a phone number; use a library with per-country rules when you need to know whether it could be a real one. (Meridian's view)
In the North American Numbering Plan, only 555-0100 through 555-0199 are now specifically reserved for fictional use.[7]
Where you'll meet it
OpenStreetMap asks for phone numbers in international (ITU-T E.164) format, written with a plus sign, country code, area code and local number.[8] OpenStreetMap separates multiple phone numbers in one phone tag with a semicolon.[8]
Sources
- [1]E.164 : The international public telecommunication numbering plancatalogue entry
- [2]E.164secondary source
- [3]E.123 : Notation for national and international telephone numbers, e-mail addresses and web addressescatalogue entry
- [4]E.123secondary source
- [5]RFC 3966: The tel URI for Telephone Numbersstandard
- [6]google/libphonenumberdocumentation
- [7]555 (North American Numbering Plan)secondary source
- [8]Key:phoneorganisation
Detection notes
v1 migration: Was person.phone_number (and person.telephone). Locale-specific for formatting. Decompose extracts country code, area code, and digits-only version. Pattern is permissive to handle various formats.
Use it
$ finetype infer -i "+1 (555) 123-4567" --mode column
→ identity.person.phone_number
SELECT ft_infer('+1 (555) 123-4567');
-- → 'identity.person.phone_number'CAST({col} AS VARCHAR)Schema
https://meridian.online/schemas/identity.person.phone_number · Frictionless type string
finetype taxonomy identity.person.phone_number -o json-schema