Browse Source

JS: libphonenumber 3.7

pull/567/head
Nikolaos Trogkanis 15 years ago
committed by Mihaela Rosca
parent
commit
c77db4ea53
8 changed files with 334 additions and 236 deletions
  1. +3
    -1
      javascript/README
  2. +22
    -6
      javascript/i18n/phonenumbers/asyoutypeformatter.js
  3. +24
    -1
      javascript/i18n/phonenumbers/asyoutypeformatter_test.js
  4. +86
    -71
      javascript/i18n/phonenumbers/metadata.js
  5. +5
    -3
      javascript/i18n/phonenumbers/metadatafortesting.js
  6. +86
    -71
      javascript/i18n/phonenumbers/metadatalite.js
  7. +79
    -75
      javascript/i18n/phonenumbers/phonenumberutil.js
  8. +29
    -8
      javascript/i18n/phonenumbers/phonenumberutil_test.js

+ 3
- 1
javascript/README View File

@ -25,7 +25,7 @@ pages with your web browser:
How to update:
==============
The JavaScript library is ported from the Java implementation (revision 206).
The JavaScript library is ported from the Java implementation (revision 278).
When the Java project gets updated follow these steps to update the JavaScript
project:
@ -65,3 +65,5 @@ TODO:
=====
Port functionality to extract phone-numbers from text (findNumbers).
Port offline phone number geocoder.
Enable PhoneNumberUtil to handle all digits, rather than a subset
(JavaScript has no equivalent to the Java Character.digit).

+ 22
- 6
javascript/i18n/phonenumbers/asyoutypeformatter.js View File

@ -227,6 +227,9 @@ i18n.phonenumbers.AsYouTypeFormatter.MIN_LEADING_DIGITS_LENGTH_ = 3;
/**
* The metadata needed by this class is the same for all regions sharing the
* same country calling code. Therefore, we return the metadata for "main"
* region for this country calling code.
* @param {string} regionCode
* @return {i18n.phonenumbers.PhoneMetadata}
* @private
@ -234,8 +237,13 @@ i18n.phonenumbers.AsYouTypeFormatter.MIN_LEADING_DIGITS_LENGTH_ = 3;
i18n.phonenumbers.AsYouTypeFormatter.prototype.getMetadataForRegion_ =
function(regionCode) {
/** @type {number} */
var countryCallingCode = this.phoneUtil_.getCountryCodeForRegion(regionCode);
/** @type {string} */
var mainCountry =
this.phoneUtil_.getRegionCodeForCountryCode(countryCallingCode);
/** @type {i18n.phonenumbers.PhoneMetadata} */
var metadata = this.phoneUtil_.getMetadataForRegion(regionCode);
var metadata = this.phoneUtil_.getMetadataForRegion(mainCountry);
if (metadata != null) {
return metadata;
}
@ -377,7 +385,7 @@ i18n.phonenumbers.AsYouTypeFormatter.prototype.createFormattingTemplate_ =
/** @type {string} */
var tempTemplate = this.getFormattingTemplate_(numberPattern,
format.getFormatOrDefault());
if (tempTemplate.length > this.nationalNumber_.getLength()) {
if (tempTemplate.length > 0) {
this.formattingTemplate_.append(tempTemplate);
return true;
}
@ -406,6 +414,11 @@ i18n.phonenumbers.AsYouTypeFormatter.prototype.getFormattingTemplate_ =
// this match will always succeed
/** @type {string} */
var aPhoneNumber = m[0];
// No formatting template can be created if the number of digits entered so
// far is longer than the maximum the current formatting rule can accommodate.
if (aPhoneNumber.length < this.nationalNumber_.getLength()) {
return '';
}
// Formats the number according to numberFormat
/** @type {string} */
var template = aPhoneNumber.replace(new RegExp(numberPattern, 'g'),
@ -811,17 +824,20 @@ i18n.phonenumbers.AsYouTypeFormatter.prototype.
normalizeAndAccrueDigitsAndPlusSign_ = function(nextChar,
rememberPosition) {
/** @type {string} */
var normalizedChar;
if (nextChar == i18n.phonenumbers.PhoneNumberUtil.PLUS_SIGN) {
normalizedChar = nextChar;
this.accruedInputWithoutFormatting_.append(nextChar);
} else {
nextChar = i18n.phonenumbers.PhoneNumberUtil.DIGIT_MAPPINGS[nextChar];
this.accruedInputWithoutFormatting_.append(nextChar);
this.nationalNumber_.append(nextChar);
normalizedChar = i18n.phonenumbers.PhoneNumberUtil.DIGIT_MAPPINGS[nextChar];
this.accruedInputWithoutFormatting_.append(normalizedChar);
this.nationalNumber_.append(normalizedChar);
}
if (rememberPosition) {
this.positionToRemember_ = this.accruedInputWithoutFormatting_.getLength();
}
return nextChar;
return normalizedChar;
};


+ 24
- 1
javascript/i18n/phonenumbers/asyoutypeformatter_test.js View File

@ -47,6 +47,29 @@ function testInvalidRegion() {
assertEquals('650253', f.inputDigit('3'));
}
function testTooLongNumberMatchingMultipleLeadingDigits() {
// See http://code.google.com/p/libphonenumber/issues/detail?id=36
// The bug occurred last time for countries which have two formatting rules
// with exactly the same leading digits pattern but differ in length.
/** @type {i18n.phonenumbers.AsYouTypeFormatter} */
var f = new i18n.phonenumbers.AsYouTypeFormatter('ZZ');
assertEquals('+', f.inputDigit('+'));
assertEquals('+8', f.inputDigit('8'));
assertEquals('+81 ', f.inputDigit('1'));
assertEquals('+81 9', f.inputDigit('9'));
assertEquals('+81 90', f.inputDigit('0'));
assertEquals('+81 90 1', f.inputDigit('1'));
assertEquals('+81 90 12', f.inputDigit('2'));
assertEquals('+81 90 123', f.inputDigit('3'));
assertEquals('+81 90 1234', f.inputDigit('4'));
assertEquals('+81 90 1234 5', f.inputDigit('5'));
assertEquals('+81 90 1234 56', f.inputDigit('6'));
assertEquals('+81 90 1234 567', f.inputDigit('7'));
assertEquals('+81 90 1234 5678', f.inputDigit('8'));
assertEquals('+81 90 12 345 6789', f.inputDigit('9'));
assertEquals('+81901234567890', f.inputDigit('0'));
}
function testAYTFUS() {
/** @type {i18n.phonenumbers.AsYouTypeFormatter} */
var f = new i18n.phonenumbers.AsYouTypeFormatter('US');
@ -341,7 +364,7 @@ function testAYTFGBFixedLine() {
function testAYTFGBTollFree() {
/** @type {i18n.phonenumbers.AsYouTypeFormatter} */
var f = new i18n.phonenumbers.AsYouTypeFormatter('gb');
var f = new i18n.phonenumbers.AsYouTypeFormatter('GB');
assertEquals('0', f.inputDigit('0'));
assertEquals('08', f.inputDigit('8'));
assertEquals('080', f.inputDigit('0'));


+ 86
- 71
javascript/i18n/phonenumbers/metadata.js View File

@ -17,7 +17,7 @@
/**
* @fileoverview Generated metadata for file
* resources/PhoneNumberMetaData.xml
* ../resources/PhoneNumberMetaData.xml
* @author Nikolaos Trogkanis
*/
@ -635,15 +635,17 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"BG":[,[,,"[2-9]\\d{6,8}","\\d{7,9}"]
,[,,"(?:2\\d|[36]\\d|5[1-9]|8[1-6]|9[1-7])\\d{5,6}|(?:4(?:[124-7]\\d|3[1-6])|7(?:0[1-9]|[1-9]\\d))\\d{4,5}","\\d{7,8}",,,"2123456"]
,"BG":[,[,,"[23567]\\d{5,7}|[489]\\d{6,8}","\\d{5,9}"]
,[,,"2(?:[0-8]\\d{5,6}|9\\d{4,6})|(?:[36]\\d|5[1-9]|8[1-6]|9[1-7])\\d{5,6}|(?:4(?:[124-7]\\d|3[1-6])|7(?:0[1-9]|[1-9]\\d))\\d{4,5}","\\d{5,8}",,,"2123456"]
,[,,"(?:8[7-9]|98)\\d{7}|4(?:3[0789]|8\\d)\\d{5}","\\d{8,9}",,,"48123456"]
,[,,"800\\d{5}","\\d{8}",,,"80012345"]
,[,,"90\\d{6}","\\d{8}",,,"90123456"]
,[,,"NA","NA"]
,[,,"700\\d{5}","\\d{7,9}",,,"70012345"]
,[,,"700\\d{5}","\\d{5,9}",,,"70012345"]
,[,,"NA","NA"]
,"BG",359,"00","0",,,"0",,,,[[,"(2)(\\d{3})(\\d{3,4})","$1/$2 $3",["2"]
,"BG",359,"00","0",,,"0",,,,[[,"(2)(\\d{5})","$1/$2",["29"]
,"0$1",""]
,[,"(2)(\\d{3})(\\d{3,4})","$1/$2 $3",["2"]
,"0$1",""]
,[,"(\\d{3})(\\d{4})","$1/$2",["43[124-7]|70[1-9]"]
,"0$1",""]
@ -1100,7 +1102,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"90[059]\\d{7}","\\d{10}",,,"9001234567"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"4000\\d{4}","\\d{8}",,,"40001234"]
,[,,"40[02]0\\d{4}","\\d{8}",,,"40001234"]
,"CR",506,"00",,,,"(1900)",,,,[[,"(\\d{4})(\\d{4})","$1 $2",["[24]|8[3-9]"]
,"","$CC $1"]
,[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]0"]
@ -1328,7 +1330,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"800[2-9]\\d{3}","\\d{7}",,,"8002123"]
,[,,"NA","NA"]
]
,"EG":[,[,,"1\\d{4,9}|[2-689]\\d{7,9}","\\d{5,10}"]
,"EG":[,[,,"1\\d{4,9}|[2456]\\d{8}|3\\d{7}|[89]\\d{8,9}","\\d{5,10}"]
,[,,"(?:1[35][23]|2[23]\\d|3\\d|4(?:0[2-4]|[578][23]|64)|5(?:0[234]|[57][23])|6[24-689]3|8(?:[28][2-4]|42|6[23])|9(?:[25]2|3[24]|6[23]|7[2-4]))\\d{6}|1[69]\\d{3}","\\d{5,9}",,,"234567890"]
,[,,"1[0-246-9]\\d{7}","\\d{9}",,,"101234567"]
,[,,"800\\d{7}","\\d{10}",,,"8001234567"]
@ -1363,7 +1365,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
]
,"ES":[,[,,"[5-9]\\d{8}","\\d{9}"]
,[,,"(?:8(?:[13]0|[28][0-8]|[47][1-9]|5[01346-9]|6[0457-9])|9(?:[1238][0-8]|[47][1-9]|[56]\\d))\\d{6}","\\d{9}",,,"810123456"]
,[,,"6\\d{8}","\\d{9}",,,"612345678"]
,[,,"(?:6\\d|7[1-4])\\d{7}","\\d{9}",,,"612345678"]
,[,,"[89]00\\d{6}","\\d{9}",,,"800123456"]
,[,,"80[367]\\d{6}","\\d{9}",,,"803123456"]
,[,,"90[12]\\d{6}","\\d{9}",,,"901123456"]
@ -1544,18 +1546,18 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,"473",[,,"NA","NA"]
,[,,"NA","NA"]
]
,"GE":[,[,,"[13-79]\\d{7}|8\\d{8}","\\d{5,9}"]
,[,,"(?:3(?:[256]\\d|4[124-9]|7[0-4])|4(?:1\\d|2[2-7]|3[1-79]|4[2-8]|7[239]|9[1-7]))\\d{5}","\\d{5,8}",,,"32123456"]
,[,,"(?:14|5[01578]|6[28]|7[0147-9]|9[0-35-9])\\d{6}","\\d{8}",,,"55123456"]
,"GE":[,[,,"[3458]\\d{8}","\\d{6,9}"]
,[,,"(?:3(?:[256]\\d|4[124-9]|7[0-4])|4(?:1\\d|2[2-7]|3[1-79]|4[2-8]|7[239]|9[1-7]))\\d{6}","\\d{6,9}",,,"322123456"]
,[,,"5(?:14|5[01578]|68|7[0147-9]|9[0-35-9])\\d{6}","\\d{9}",,,"555123456"]
,[,,"800\\d{6}","\\d{9}",,,"800123456"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"GE",995,"8~10","8",,,"8",,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-79]"]
,"8 $1",""]
,[,"(800)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]
,"GE",995,"8~10","8",,,"8",,,,[[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"]
,"8 $1",""]
,[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5"]
,"$1",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
@ -1589,7 +1591,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
]
,"GH":[,[,,"[235]\\d{6,8}","\\d{7,9}"]
,[,,"3(?:0[237]\\d|[167](?:2[0-6]|7\\d)|2(?:2[0-5]|7\\d)|3(?:2[0-37]|7\\d)|4(?:[27]\\d|30)|5(?:2[0-7]|7\\d)|8(?:2[0-2]|7\\d)|9(?:20|7\\d))\\d{5}","\\d{7,9}",,,"302345678"]
,[,,"(?:2[034678]|54)\\d{7}","\\d{9}",,,"231234567"]
,[,,"(?:2[034678]|5[47])\\d{7}","\\d{9}",,,"231234567"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
@ -2054,7 +2056,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"0(?:[26]\\d{4,9}|[13-57-9](?:[0159]\\d{4,8}|[2-46-8]\\d{5,8}))","\\d{6,11}",,,"0212345678"]
,[,,"3\\d{8,9}","\\d{9,10}",,,"312345678"]
,[,,"80(?:0\\d{6}|3\\d{3})","\\d{6,9}",,,"800123456"]
,[,,"89(?:2\\d{3}|9\\d{6})","\\d{6,9}",,,"899123456"]
,[,,"0878\\d{5}|1(?:44|6[346])\\d{6}|89(?:2\\d{3}|9\\d{6})","\\d{6,9}",,,"899123456"]
,[,,"84[78]\\d{6,7}","\\d{9,10}",,,"8481234567"]
,[,,"178\\d{6,7}","\\d{9,10}",,,"1781234567"]
,[,,"NA","NA"]
@ -2072,9 +2074,9 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,"",""]
,[,"(0\\d{3})(\\d{4,6})","$1 $2",["0[13-57-9][2-46-8]"]
,"",""]
,[,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13]|8(?:00|4[78])"]
,[,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13]|8(?:00|4[78]|99)"]
,"",""]
,[,"(\\d{3})(\\d{3,6})","$1 $2",["8(?:03|9)"]
,[,"(\\d{3})(\\d{3,6})","$1 $2",["8(?:03|92)"]
,"",""]
]
,,[,,"NA","NA"]
@ -2124,10 +2126,10 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"8(?:10|[78]\\d)\\d{5}","\\d{8}",,,"87101234"]
]
,"JP":[,[,,"\\d{9,10}","\\d{9,10}"]
,[,,"(?:1(?:1[236-8]|2[3-6]|3[3-9]|4[2-6]|[58][2-8]|6[2-7]|7[2-9]|9[1-8])|2[2-9]\\d|[36][1-9]\\d|4(?:6[0235-8]|[2-578]\\d|9[2-59])|5(?:6[1-9]|7[2-8]|[2-589]\\d)|7(?:3[4-9]|4[02-9]|[25-9]\\d)|8(?:3[2-9]|4[5-9]|5[1-9]|8[03-9]|[2679]\\d)|9(?:[679][1-9]|[2-58]\\d))\\d{6}","\\d{9}",,,"312345678"]
,"JP":[,[,,"[1-9]\\d{8,9}|0(?:7\\d{5,6}|8\\d{7})","\\d{7,10}"]
,[,,"(?:1(?:1[235-8]|2[3-6]|3[3-9]|4[2-6]|[58][2-8]|6[2-7]|7[2-9]|9[1-9])|2[2-9]\\d|[36][1-9]\\d|4(?:6[02-8]|[2-578]\\d|9[2-59])|5(?:6[1-9]|7[2-8]|[2-589]\\d)|7(?:3[4-9]|4[02-9]|[25-9]\\d)|8(?:3[2-9]|4[5-9]|5[1-9]|8[03-9]|[2679]\\d)|9(?:[679][1-9]|[2-58]\\d))\\d{6}","\\d{9}",,,"312345678"]
,[,,"(?:[79]0\\d|80[1-9])\\d{7}","\\d{10}",,,"7012345678"]
,[,,"120\\d{6}|800\\d{7}","\\d{9,10}",,,"120123456"]
,[,,"120\\d{6}|800\\d{7}|0(?:777(?:[01]\\d{2}|5\\d{3})|882[1245]\\d{4})","\\d{7,10}",,,"120123456"]
,[,,"990\\d{6}","\\d{9}",,,"990123456"]
,[,,"NA","NA"]
,[,,"60\\d{7}","\\d{9}",,,"601234567"]
@ -2136,6 +2138,10 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,"0$1",""]
,[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"]
,"0$1",""]
,[,"(\\d{3})(\\d{4,5})","$1-$2",["077"]
,"0$1",""]
,[,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["088"]
,"0$1",""]
,[,"(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[2579]0|80[1-9]"]
,"0$1",""]
,[,"(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|5(?:76|97)|499|746|8(?:3[89]|63|47|51)|9(?:49|80|9[16])","1(?:267|3(?:7[247]|9[278])|4(?:5[67]|66)|5(?:47|58|64|8[67])|6(?:3[245]|48|5[4-68]))|5(?:76|97)9|499[2468]|7468|8(?:3(?:8[78]|96)|636|477|51[24])|9(?:496|802|9(?:1[23]|69))","1(?:267|3(?:7[247]|9[278])|4(?:5[67]|66)|5(?:47|58|64|8[67])|6(?:3[245]|48|5[4-68]))|5(?:769|979[2-69])|499[2468]|7468|8(?:3(?:8[78]|96[2457-9])|636[2-57-9]|477|51[24])|9(?:496|802|9(?:1[23]|69))"]
@ -2152,9 +2158,9 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,"0$1",""]
]
,,[,,"20\\d{8}","\\d{10}",,,"2012345678"]
,,,[,,"NA","NA"]
,,,[,,"0(?:777(?:[01]\\d{2}|5\\d{3})|882[1245]\\d{4})","\\d{7,9}",,,"0777012"]
,[,,"570\\d{6}","\\d{9}",,,"570123456"]
]
,1]
,"KE":[,[,,"\\d{6,10}","\\d{4,10}"]
,[,,"(?:20|4[0-6]|5\\d|6[0-24-9])\\d{4,7}","\\d{4,9}",,,"202012345"]
,[,,"7(?:0[0-3]|[123]\\d|5[0-3]|7[0-4])\\d{6}","\\d{9}",,,"712123456"]
@ -2302,7 +2308,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
]
,"KW":[,[,,"[12569]\\d{6,7}","\\d{7,8}"]
,[,,"(?:18\\d|2(?:[23]\\d{2}|4[1-35-9]\\d|5(?:0[034]|[2-46]\\d|5[1-3]|7[1-7])))\\d{4}","\\d{7,8}",,,"22345678"]
,[,,"(?:5(?:0[0-2]|5\\d)|6(?:0[034679]|5[015-9]|6\\d|7[067]|99)|9(?:0[09]|4[049]|66|[79]\\d))\\d{5}","\\d{8}",,,"50012345"]
,[,,"(?:5(?:0[0-25]|5\\d)|6(?:0[034679]|5[015-9]|6\\d|7[067]|99)|9(?:0[09]|4[049]|66|[79]\\d))\\d{5}","\\d{8}",,,"50012345"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
@ -2331,7 +2337,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
]
,"KZ":[,[,,"(?:7\\d{2}|80[09])\\d{7}","\\d{10}"]
,[,,"7(?:1(?:0(?:[23]\\d|4[023]|59|63)|1(?:[23]\\d|4[0-79]|59)|2(?:[23]\\d|59)|3(?:2\\d|3[1-79]|4[0-35-9]|59)|4(?:2\\d|3[013-79]|4[0-8]|5[1-79])|5(?:2\\d|3[1-8]|4[1-7]|59)|6(?:2\\d|[34]\\d|5[19]|61)|72\\d|8(?:[27]\\d|3[1-46-9]|4[0-5]|))|2(?:1(?:[23]\\d|4[46-9]|5[3469])|2(?:2\\d|3[0679]|46|5[12679]|)|3(?:[234]\\d|5[139]|)|4(?:2\\d|3[1235-9]|59)|5(?:[23]\\d|4[01246-8]|59|61)|6(?:2\\d|3[1-9]|4[0-4]|59)|7(?:[23]\\d|40|5[279]|7\\d)|8(?:[23]\\d|4[0-3]|59)|9(?:2\\d|3[124578]|59))|3622)\\d{5}","\\d{10}",,,"7123456789"]
,[,,"7(?:0[01257]\\d{2}|6[02-4]\\d{2}|7[157]\\d{2})\\d{5}","\\d{10}",,,"7710009998"]
,[,,"7(?:0[01257]|6[02-4]|7[157])\\d{7}","\\d{10}",,,"7710009998"]
,[,,"800\\d{7}","\\d{10}",,,"8001234567"]
,[,,"809\\d{7}","\\d{10}",,,"8091234567"]
,[,,"NA","NA"]
@ -2638,15 +2644,17 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"MH":[,[]
,[]
,[]
,"MH":[,[,,"[2-6]\\d{6}","\\d{7}"]
,[,,"(?:247|528|625)\\d{4}","\\d{7}",,,"2471234"]
,[,,"(?:235|329|45[56]|545)\\d{4}","\\d{7}",,,"2351234"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"MH",692,"011","1",,,"1",,,1,,,[,,"NA","NA"]
,[,,"635\\d{4}","\\d{7}",,,"6351234"]
,"MH",692,"011","1",,,"1",,,,[[,"(\\d{3})(\\d{4})","$1-$2",,"",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
@ -2746,8 +2754,8 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
]
,"MP":[,[,,"[5689]\\d{9}","\\d{7}(?:\\d{3})?"]
,[,,"670(?:2(?:3[3-5]|88|56)|32[23]|4[38]3|532|6(?:64|70|8\\d))\\d{4}","\\d{7}(?:\\d{3})?",,,"6702345678"]
,[,,"670(?:2(?:3[3-5]|88|56)|32[23]|4[38]3|532|6(?:64|70|8\\d))\\d{4}","\\d{7}(?:\\d{3})?",,,"6702345678"]
,[,,"670(?:2(?:3[3-7]|56|8[5-8])|32[1238]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[589]|8[3-9]8|989)\\d{4}","\\d{7}(?:\\d{3})?",,,"6702345678"]
,[,,"670(?:2(?:3[3-7]|56|8[5-8])|32[1238]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[589]|8[3-9]8|989)\\d{4}","\\d{7}(?:\\d{3})?",,,"6702345678"]
,[,,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",,,"8002123456"]
,[,,"900[2-9]\\d{6}","\\d{10}",,,"9002123456"]
,[,,"NA","NA"]
@ -2812,16 +2820,16 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
]
,"MU":[,[,,"[2-9]\\d{6}","\\d{7}"]
,[,,"(?:2(?:[034789]\\d|1[0-8]|2[0-79])|4(?:[013-8]\\d|2[4-7])|[56]\\d{2}|8(?:14|3[129]))\\d{4}","\\d{7}",,,"2012345"]
,[,,"(?:25\\d|4(?:2[12389]|9\\d)|7\\d{2}|87[15-7]|9[1-8]\\d)\\d{4}","\\d{7}",,,"2512345"]
,[,,"(?:2(?:[034789]\\d|1[0-7])|4(?:[013-8]\\d|2[4-7])|[56]\\d{2}|8(?:14|3[129]))\\d{4}","\\d{7}",,,"2012345"]
,[,,"(?:25\\d|4(?:2[12389]|9\\d)|7\\d{2}|87[15-8]|9[1-8]\\d)\\d{4}","\\d{7}",,,"2512345"]
,[,,"80[012]\\d{4}","\\d{7}",,,"8001234"]
,[,,"30\\d{5}","\\d{7}",,,"3012345"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"3(?:20|9\\d)\\d{4}","\\d{7}",,,"3201234"]
,"MU",230,"0(?:[2-7]0|33)",,,,,,"020",,[[,"([2-9]\\d{2})(\\d{4})","$1 $2",,"",""]
]
,,[,,"NA","NA"]
,,[,,"2(?:1[89]|2\\d)\\d{4}","\\d{7}",,,"2181234"]
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
@ -3186,15 +3194,17 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,"PE":[,[,,"[14-9]\\d{7,8}","\\d{6,9}"]
,[,,"(?:1\\d|4[1-4]|5[1-46]|6[1-7]|7[2-46]|8[2-4])\\d{6}","\\d{6,8}",,,"11234567"]
,[,,"9\\d{8}","\\d{9}",,,"912345678"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"800\\d{5}","\\d{8}",,,"80012345"]
,[,,"805\\d{5}","\\d{8}",,,"80512345"]
,[,,"801\\d{5}","\\d{8}",,,"80112345"]
,[,,"80[24]\\d{5}","\\d{8}",,,"80212345"]
,[,,"NA","NA"]
,"PE",51,"19(?:1[124]|77|90)00","0"," Anexo ",,"0",,,,[[,"(1)(\\d{7})","$1 $2",["1"]
,"($1)",""]
,[,"([4-8]\\d)(\\d{6})","$1 $2",["[4-8]"]
,"($1)",""]
,"(0$1)",""]
,[,"([4-8]\\d)(\\d{6})","$1 $2",["[4-7]|8[2-4]"]
,"(0$1)",""]
,[,"(\\d{3})(\\d{5})","$1 $2",["80"]
,"(0$1)",""]
,[,"(9\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"]
,"$1",""]
]
@ -3204,7 +3214,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
]
,"PF":[,[,,"[2-9]\\d{5}","\\d{6}"]
,[,,"(?:36\\d|4(?:[02-9]\\d|1[02-9])|[5689]\\d{2})\\d{3}","\\d{6}",,,"401234"]
,[,,"(?:[27]\\d{3}|3[0-49]\\d{2}|411[3-6])\\d{2}","\\d{6}",,,"212345"]
,[,,"(?:[27]\\d{3}|3[0-59]\\d{2}|411[3-6])\\d{2}","\\d{6}",,,"212345"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
@ -3306,15 +3316,17 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"PM":[,[]
,[]
,[]
,"PM":[,[,,"[45]\\d{5}","\\d{6}"]
,[,,"41\\d{4}","\\d{6}",,,"411234"]
,[,,"55\\d{4}","\\d{6}",,,"551234"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"PM",508,"00","0",,,"0",,,1,,,[,,"NA","NA"]
,"PM",508,"00","0",,,"0",,,,[[,"([45]\\d)(\\d{2})(\\d{2})","$1 $2 $3",,"0$1",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
@ -3486,23 +3498,25 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,1,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"RW":[,[,,"[27-9]\\d{8}","\\d{9}"]
,[,,"25\\d{7}","\\d{9}",,,"250123456"]
,"RW":[,[,,"[027-9]\\d{7,8}","\\d{8,9}"]
,[,,"2[258]\\d{7}|06\\d{6}","\\d{8,9}",,,"250123456"]
,[,,"7[258]\\d{7}","\\d{9}",,,"720123456"]
,[,,"800\\d{6}","\\d{9}",,,"800123456"]
,[,,"900\\d{6}","\\d{9}",,,"900123456"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"RW",250,"000","0",,,"0",,,,[[,"(25\\d)(\\d{3})(\\d{3})","$1 $2 $3",["2"]
,"RW",250,"00","0",,,"0",,,,[[,"(2\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"]
,"$1",""]
,[,"([7-9]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"]
,"0$1",""]
,[,"(0\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]
,"",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,1]
,"SA":[,[,,"[1-9]\\d{7,10}","\\d{7,11}"]
,[,,"(?:1[24-7]|2[24-8]|3[35-8]|4[34-68]|6[2-5]|7[235-7])\\d{6}","\\d{7,8}",,,"12345678"]
,[,,"(?:5[013-69]\\d|8111)\\d{6}","\\d{9,10}",,,"512345678"]
@ -3538,17 +3552,17 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"SC":[,[,,"[2-8]\\d{5,6}","\\d{6,7}"]
,[,,"(?:2?(?:55[0-5]|78[013])|4?(?:2(?:1[78]|2[14-69]|3[2-4]|4[1-36-8]|6[167]|[89]\\d)|3(?:0[34]|2[1-6]|4[4-6]|55|6[016]|7\\d|8[0-589]|9[0-5])|6(?:0[0-256]|1[0-478]|2[145]|3[02-4]|4[124]|6[015]|7\\d|8[1-3])))\\d{3}","\\d{6,7}",,,"4217123"]
,"SC":[,[,,"[2-9]\\d{5,6}","\\d{6,7}"]
,[,,"(?:2?(?:55[0-5]|78[013])|4?(?:2(?:0[589]|1[03-9]|[2-9]\\d)|[36]\\d{2})|44\\d{2})\\d{3}","\\d{6,7}",,,"4217123"]
,[,,"2?(?:5(?:[0-46-9]\\d|5[6-9])|7(?:[0-79]\\d|8[24-9]))\\d{3}","\\d{6,7}",,,"2510123"]
,[,,"8000\\d{2}","\\d{6}",,,"800000"]
,[,,"98\\d{4}","\\d{6}",,,"981234"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"(?:44[1-3]|647)\\d{4}","\\d{7}",,,"4410123"]
,"SC",248,"0[0-2]",,,,,,"00",,[[,"(\\d{3})(\\d{3})","$1 $2",["[3578]|2[1-4689]|6(?:[0-35-9]|4[0-689])"]
,[,,"64\\d{5}","\\d{7}",,,"6412345"]
,"SC",248,"0[0-2]",,,,,,"00",,[[,"(\\d{3})(\\d{3})","$1 $2",["[35789]|2[1-4689]|6[0-35-9]"]
,"",""]
,[,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["2[57]|4[2-46]|647"]
,[,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["2[57]|4|64"]
,"",""]
]
,,[,,"NA","NA"]
@ -3824,7 +3838,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
]
,"SY":[,[,,"[1-59]\\d{7,8}","\\d{6,9}"]
,[,,"(?:1(?:1\\d?|4\\d|[2356])|2[1-35]|3(?:1\\d|[34])|4[13]|5[1-3])\\d{6}","\\d{6,9}",,,"112345678"]
,[,,"(?:1(?:1\\d?|4\\d|[2356])|2[1-35]|3(?:[13]\\d|4)|4[13]|5[1-3])\\d{6}","\\d{6,9}",,,"112345678"]
,[,,"9(?:3[23]|4[457]|55|6[67]|88|9[1-49])\\d{6}","\\d{9}",,,"944567890"]
,[,,"NA","NA"]
,[,,"NA","NA"]
@ -3893,15 +3907,16 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"TG":[,[,,"[02-9]\\d{6}","\\d{7}"]
,[,,"(?:2[2-7]|3[23]|44|55|66|77)\\d{5}","\\d{7}",,,"2212345"]
,[,,"(?:0[1-9]|7[56]|8[1-7]|9\\d)\\d{5}","\\d{7}",,,"0112345"]
,"TG":[,[,,"[02-9]\\d{6,7}","\\d{7,8}"]
,[,,"2?(?:2[2-7]|3[23]|44|55|66|77)\\d{5}","\\d{7,8}",,,"22212345"]
,[,,"(?:0[1-9]|7[56]|8[1-7]|9\\d)\\d{5}|9[0-289]\\d{6}","\\d{7,8}",,,"90112345"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"TG",228,"00",,,,,,,,[[,"(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",,"",""]
,[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,"",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
@ -3938,7 +3953,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
,"TJ",992,"8~10","8",,,"8",,,,[[,"([349]\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[34]7|91[78]"]
,"(8) $1",""]
,[,"([459]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[48]|5|9(?:19|[0235-9])"]
,[,"([459]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[48]|5|9(?:1[59]|[0235-9])"]
,"(8) $1",""]
,[,"(331700)(\\d)(\\d{2})","$1 $2 $3",["331","3317","33170","331700"]
,"(8) $1",""]
@ -3949,9 +3964,9 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"TK":[,[]
,[]
,[]
,"TK":[,[,,"[1-9]\\d{3}","\\d{4}",,,"3190"]
,[,,"[1-9]\\d{3}","\\d{4}",,,"3190"]
,[,,"[1-9]\\d{3}","\\d{4}",,,"3190"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
@ -4147,8 +4162,8 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
,[,,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",,,"5002345678"]
,[,,"NA","NA"]
,"US",1,"011","1",,,"1",,,1,[[,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",,"",""]
,[,"(\\d{3})(\\d{4})","$1-$2",,"",""]
,"US",1,"011","1",,,"1",,,1,[[,"(\\d{3})(\\d{4})","$1-$2",,"",""]
,[,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",,"",""]
]
,[[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3"]
]
@ -4282,7 +4297,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"VU":[,[,,"[2-578]\\d{4,6}","\\d{5,7}"]
,"VU":[,[,,"[2-57-9]\\d{4,6}","\\d{5,7}"]
,[,,"(?:2[2-9]\\d|3(?:[67]\\d|8[0-8])|48[4-9]|88\\d)\\d{2}","\\d{5}",,,"22123"]
,[,,"(?:5(?:7[2-5]|[3-69]\\d)|7[013-7]\\d)\\d{4}","\\d{7}",,,"5912345"]
,[,,"NA","NA"]
@ -4290,12 +4305,12 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"VU",678,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2",["[57]"]
,"VU",678,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2",["[579]"]
,"",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
,[,,"30\\d{3}","\\d{5}",,,"30123"]
,[,,"30\\d{3}|900\\d{4}","\\d{5,7}",,,"30123"]
]
,"WF":[,[,,"[5-7]\\d{5}","\\d{6}"]
,[,,"(?:50|68|72)\\d{4}","\\d{6}",,,"501234"]


+ 5
- 3
javascript/i18n/phonenumbers/metadatafortesting.js View File

@ -17,7 +17,7 @@
/**
* @fileoverview Generated metadata for file
* resources/PhoneNumberMetaDataForTesting.xml
* ../resources/PhoneNumberMetaDataForTesting.xml
* @author Nikolaos Trogkanis
*/
@ -219,6 +219,8 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
,"JP",81,"010","0",,,"0",,,1,[[,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[57-9]0"]
,"0$1",""]
,[,"(\\d{2})(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[57-9]0"]
,"0$1",""]
,[,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["222|333","(?:222|333)1","(?:222|333)11"]
,"0$1",""]
,[,"(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["222|333","2221|3332","22212|3332","222120|3332"]
@ -377,8 +379,8 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"US",1,"011","1"," extn. ",,"1",,,1,[[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",,"",""]
,[,"(\\d{3})(\\d{4})","$1 $2",,"",""]
,"US",1,"011","1"," extn. ",,"1",,,1,[[,"(\\d{3})(\\d{4})","$1 $2",,"",""]
,[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",,"",""]
]
,[[,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3"]
]


+ 86
- 71
javascript/i18n/phonenumbers/metadatalite.js View File

@ -17,7 +17,7 @@
/**
* @fileoverview Generated metadata for file
* resources/PhoneNumberMetaData.xml
* ../resources/PhoneNumberMetaData.xml
* @author Nikolaos Trogkanis
*/
@ -635,15 +635,17 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"BG":[,[,,"[2-9]\\d{6,8}","\\d{7,9}"]
,[,,"(?:2\\d|[36]\\d|5[1-9]|8[1-6]|9[1-7])\\d{5,6}|(?:4(?:[124-7]\\d|3[1-6])|7(?:0[1-9]|[1-9]\\d))\\d{4,5}","\\d{7,8}"]
,"BG":[,[,,"[23567]\\d{5,7}|[489]\\d{6,8}","\\d{5,9}"]
,[,,"2(?:[0-8]\\d{5,6}|9\\d{4,6})|(?:[36]\\d|5[1-9]|8[1-6]|9[1-7])\\d{5,6}|(?:4(?:[124-7]\\d|3[1-6])|7(?:0[1-9]|[1-9]\\d))\\d{4,5}","\\d{5,8}"]
,[,,"(?:8[7-9]|98)\\d{7}|4(?:3[0789]|8\\d)\\d{5}","\\d{8,9}"]
,[,,"800\\d{5}","\\d{8}"]
,[,,"90\\d{6}","\\d{8}"]
,[,,"NA","NA"]
,[,,"700\\d{5}","\\d{7,9}"]
,[,,"700\\d{5}","\\d{5,9}"]
,[,,"NA","NA"]
,"BG",359,"00","0",,,"0",,,,[[,"(2)(\\d{3})(\\d{3,4})","$1/$2 $3",["2"]
,"BG",359,"00","0",,,"0",,,,[[,"(2)(\\d{5})","$1/$2",["29"]
,"0$1",""]
,[,"(2)(\\d{3})(\\d{3,4})","$1/$2 $3",["2"]
,"0$1",""]
,[,"(\\d{3})(\\d{4})","$1/$2",["43[124-7]|70[1-9]"]
,"0$1",""]
@ -1100,7 +1102,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"90[059]\\d{7}","\\d{10}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"4000\\d{4}","\\d{8}"]
,[,,"40[02]0\\d{4}","\\d{8}"]
,"CR",506,"00",,,,"(1900)",,,,[[,"(\\d{4})(\\d{4})","$1 $2",["[24]|8[3-9]"]
,"","$CC $1"]
,[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]0"]
@ -1328,7 +1330,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"800[2-9]\\d{3}","\\d{7}"]
,[,,"NA","NA"]
]
,"EG":[,[,,"1\\d{4,9}|[2-689]\\d{7,9}","\\d{5,10}"]
,"EG":[,[,,"1\\d{4,9}|[2456]\\d{8}|3\\d{7}|[89]\\d{8,9}","\\d{5,10}"]
,[,,"(?:1[35][23]|2[23]\\d|3\\d|4(?:0[2-4]|[578][23]|64)|5(?:0[234]|[57][23])|6[24-689]3|8(?:[28][2-4]|42|6[23])|9(?:[25]2|3[24]|6[23]|7[2-4]))\\d{6}|1[69]\\d{3}","\\d{5,9}"]
,[,,"1[0-246-9]\\d{7}","\\d{9}"]
,[,,"800\\d{7}","\\d{10}"]
@ -1363,7 +1365,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
]
,"ES":[,[,,"[5-9]\\d{8}","\\d{9}"]
,[,,"(?:8(?:[13]0|[28][0-8]|[47][1-9]|5[01346-9]|6[0457-9])|9(?:[1238][0-8]|[47][1-9]|[56]\\d))\\d{6}","\\d{9}"]
,[,,"6\\d{8}","\\d{9}"]
,[,,"(?:6\\d|7[1-4])\\d{7}","\\d{9}"]
,[,,"[89]00\\d{6}","\\d{9}"]
,[,,"80[367]\\d{6}","\\d{9}"]
,[,,"90[12]\\d{6}","\\d{9}"]
@ -1544,18 +1546,18 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,"473",[,,"NA","NA"]
,[,,"NA","NA"]
]
,"GE":[,[,,"[13-79]\\d{7}|8\\d{8}","\\d{5,9}"]
,[,,"(?:3(?:[256]\\d|4[124-9]|7[0-4])|4(?:1\\d|2[2-7]|3[1-79]|4[2-8]|7[239]|9[1-7]))\\d{5}","\\d{5,8}"]
,[,,"(?:14|5[01578]|6[28]|7[0147-9]|9[0-35-9])\\d{6}","\\d{8}"]
,"GE":[,[,,"[3458]\\d{8}","\\d{6,9}"]
,[,,"(?:3(?:[256]\\d|4[124-9]|7[0-4])|4(?:1\\d|2[2-7]|3[1-79]|4[2-8]|7[239]|9[1-7]))\\d{6}","\\d{6,9}"]
,[,,"5(?:14|5[01578]|68|7[0147-9]|9[0-35-9])\\d{6}","\\d{9}"]
,[,,"800\\d{6}","\\d{9}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"GE",995,"8~10","8",,,"8",,,,[[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[13-79]"]
,"8 $1",""]
,[,"(800)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"]
,"GE",995,"8~10","8",,,"8",,,,[[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"]
,"8 $1",""]
,[,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5"]
,"$1",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
@ -1589,7 +1591,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
]
,"GH":[,[,,"[235]\\d{6,8}","\\d{7,9}"]
,[,,"3(?:0[237]\\d|[167](?:2[0-6]|7\\d)|2(?:2[0-5]|7\\d)|3(?:2[0-37]|7\\d)|4(?:[27]\\d|30)|5(?:2[0-7]|7\\d)|8(?:2[0-2]|7\\d)|9(?:20|7\\d))\\d{5}","\\d{7,9}"]
,[,,"(?:2[034678]|54)\\d{7}","\\d{9}"]
,[,,"(?:2[034678]|5[47])\\d{7}","\\d{9}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
@ -2054,7 +2056,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"0(?:[26]\\d{4,9}|[13-57-9](?:[0159]\\d{4,8}|[2-46-8]\\d{5,8}))","\\d{6,11}"]
,[,,"3\\d{8,9}","\\d{9,10}"]
,[,,"80(?:0\\d{6}|3\\d{3})","\\d{6,9}"]
,[,,"89(?:2\\d{3}|9\\d{6})","\\d{6,9}"]
,[,,"0878\\d{5}|1(?:44|6[346])\\d{6}|89(?:2\\d{3}|9\\d{6})","\\d{6,9}"]
,[,,"84[78]\\d{6,7}","\\d{9,10}"]
,[,,"178\\d{6,7}","\\d{9,10}"]
,[,,"NA","NA"]
@ -2072,9 +2074,9 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,"",""]
,[,"(0\\d{3})(\\d{4,6})","$1 $2",["0[13-57-9][2-46-8]"]
,"",""]
,[,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13]|8(?:00|4[78])"]
,[,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13]|8(?:00|4[78]|99)"]
,"",""]
,[,"(\\d{3})(\\d{3,6})","$1 $2",["8(?:03|9)"]
,[,"(\\d{3})(\\d{3,6})","$1 $2",["8(?:03|92)"]
,"",""]
]
,,[,,"NA","NA"]
@ -2124,10 +2126,10 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"8(?:10|[78]\\d)\\d{5}","\\d{8}"]
]
,"JP":[,[,,"\\d{9,10}","\\d{9,10}"]
,[,,"(?:1(?:1[236-8]|2[3-6]|3[3-9]|4[2-6]|[58][2-8]|6[2-7]|7[2-9]|9[1-8])|2[2-9]\\d|[36][1-9]\\d|4(?:6[0235-8]|[2-578]\\d|9[2-59])|5(?:6[1-9]|7[2-8]|[2-589]\\d)|7(?:3[4-9]|4[02-9]|[25-9]\\d)|8(?:3[2-9]|4[5-9]|5[1-9]|8[03-9]|[2679]\\d)|9(?:[679][1-9]|[2-58]\\d))\\d{6}","\\d{9}"]
,"JP":[,[,,"[1-9]\\d{8,9}|0(?:7\\d{5,6}|8\\d{7})","\\d{7,10}"]
,[,,"(?:1(?:1[235-8]|2[3-6]|3[3-9]|4[2-6]|[58][2-8]|6[2-7]|7[2-9]|9[1-9])|2[2-9]\\d|[36][1-9]\\d|4(?:6[02-8]|[2-578]\\d|9[2-59])|5(?:6[1-9]|7[2-8]|[2-589]\\d)|7(?:3[4-9]|4[02-9]|[25-9]\\d)|8(?:3[2-9]|4[5-9]|5[1-9]|8[03-9]|[2679]\\d)|9(?:[679][1-9]|[2-58]\\d))\\d{6}","\\d{9}"]
,[,,"(?:[79]0\\d|80[1-9])\\d{7}","\\d{10}"]
,[,,"120\\d{6}|800\\d{7}","\\d{9,10}"]
,[,,"120\\d{6}|800\\d{7}|0(?:777(?:[01]\\d{2}|5\\d{3})|882[1245]\\d{4})","\\d{7,10}"]
,[,,"990\\d{6}","\\d{9}"]
,[,,"NA","NA"]
,[,,"60\\d{7}","\\d{9}"]
@ -2136,6 +2138,10 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,"0$1",""]
,[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"]
,"0$1",""]
,[,"(\\d{3})(\\d{4,5})","$1-$2",["077"]
,"0$1",""]
,[,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["088"]
,"0$1",""]
,[,"(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[2579]0|80[1-9]"]
,"0$1",""]
,[,"(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|5(?:76|97)|499|746|8(?:3[89]|63|47|51)|9(?:49|80|9[16])","1(?:267|3(?:7[247]|9[278])|4(?:5[67]|66)|5(?:47|58|64|8[67])|6(?:3[245]|48|5[4-68]))|5(?:76|97)9|499[2468]|7468|8(?:3(?:8[78]|96)|636|477|51[24])|9(?:496|802|9(?:1[23]|69))","1(?:267|3(?:7[247]|9[278])|4(?:5[67]|66)|5(?:47|58|64|8[67])|6(?:3[245]|48|5[4-68]))|5(?:769|979[2-69])|499[2468]|7468|8(?:3(?:8[78]|96[2457-9])|636[2-57-9]|477|51[24])|9(?:496|802|9(?:1[23]|69))"]
@ -2152,9 +2158,9 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,"0$1",""]
]
,,[,,"20\\d{8}","\\d{10}"]
,,,[,,"NA","NA"]
,,,[,,"0(?:777(?:[01]\\d{2}|5\\d{3})|882[1245]\\d{4})","\\d{7,9}"]
,[,,"570\\d{6}","\\d{9}"]
]
,1]
,"KE":[,[,,"\\d{6,10}","\\d{4,10}"]
,[,,"(?:20|4[0-6]|5\\d|6[0-24-9])\\d{4,7}","\\d{4,9}"]
,[,,"7(?:0[0-3]|[123]\\d|5[0-3]|7[0-4])\\d{6}","\\d{9}"]
@ -2302,7 +2308,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
]
,"KW":[,[,,"[12569]\\d{6,7}","\\d{7,8}"]
,[,,"(?:18\\d|2(?:[23]\\d{2}|4[1-35-9]\\d|5(?:0[034]|[2-46]\\d|5[1-3]|7[1-7])))\\d{4}","\\d{7,8}"]
,[,,"(?:5(?:0[0-2]|5\\d)|6(?:0[034679]|5[015-9]|6\\d|7[067]|99)|9(?:0[09]|4[049]|66|[79]\\d))\\d{5}","\\d{8}"]
,[,,"(?:5(?:0[0-25]|5\\d)|6(?:0[034679]|5[015-9]|6\\d|7[067]|99)|9(?:0[09]|4[049]|66|[79]\\d))\\d{5}","\\d{8}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
@ -2331,7 +2337,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
]
,"KZ":[,[,,"(?:7\\d{2}|80[09])\\d{7}","\\d{10}"]
,[,,"7(?:1(?:0(?:[23]\\d|4[023]|59|63)|1(?:[23]\\d|4[0-79]|59)|2(?:[23]\\d|59)|3(?:2\\d|3[1-79]|4[0-35-9]|59)|4(?:2\\d|3[013-79]|4[0-8]|5[1-79])|5(?:2\\d|3[1-8]|4[1-7]|59)|6(?:2\\d|[34]\\d|5[19]|61)|72\\d|8(?:[27]\\d|3[1-46-9]|4[0-5]|))|2(?:1(?:[23]\\d|4[46-9]|5[3469])|2(?:2\\d|3[0679]|46|5[12679]|)|3(?:[234]\\d|5[139]|)|4(?:2\\d|3[1235-9]|59)|5(?:[23]\\d|4[01246-8]|59|61)|6(?:2\\d|3[1-9]|4[0-4]|59)|7(?:[23]\\d|40|5[279]|7\\d)|8(?:[23]\\d|4[0-3]|59)|9(?:2\\d|3[124578]|59))|3622)\\d{5}","\\d{10}"]
,[,,"7(?:0[01257]\\d{2}|6[02-4]\\d{2}|7[157]\\d{2})\\d{5}","\\d{10}"]
,[,,"7(?:0[01257]|6[02-4]|7[157])\\d{7}","\\d{10}"]
,[,,"800\\d{7}","\\d{10}"]
,[,,"809\\d{7}","\\d{10}"]
,[,,"NA","NA"]
@ -2638,15 +2644,17 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"MH":[,[]
,[]
,[]
,"MH":[,[,,"[2-6]\\d{6}","\\d{7}"]
,[,,"(?:247|528|625)\\d{4}","\\d{7}"]
,[,,"(?:235|329|45[56]|545)\\d{4}","\\d{7}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"MH",692,"011","1",,,"1",,,1,,,[,,"NA","NA"]
,[,,"635\\d{4}","\\d{7}"]
,"MH",692,"011","1",,,"1",,,,[[,"(\\d{3})(\\d{4})","$1-$2",,"",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
@ -2746,8 +2754,8 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
]
,"MP":[,[,,"[5689]\\d{9}","\\d{7}(?:\\d{3})?"]
,[,,"670(?:2(?:3[3-5]|88|56)|32[23]|4[38]3|532|6(?:64|70|8\\d))\\d{4}","\\d{7}(?:\\d{3})?"]
,[,,"670(?:2(?:3[3-5]|88|56)|32[23]|4[38]3|532|6(?:64|70|8\\d))\\d{4}","\\d{7}(?:\\d{3})?"]
,[,,"670(?:2(?:3[3-7]|56|8[5-8])|32[1238]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[589]|8[3-9]8|989)\\d{4}","\\d{7}(?:\\d{3})?"]
,[,,"670(?:2(?:3[3-7]|56|8[5-8])|32[1238]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[589]|8[3-9]8|989)\\d{4}","\\d{7}(?:\\d{3})?"]
,[,,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}"]
,[,,"900[2-9]\\d{6}","\\d{10}"]
,[,,"NA","NA"]
@ -2812,16 +2820,16 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
]
,"MU":[,[,,"[2-9]\\d{6}","\\d{7}"]
,[,,"(?:2(?:[034789]\\d|1[0-8]|2[0-79])|4(?:[013-8]\\d|2[4-7])|[56]\\d{2}|8(?:14|3[129]))\\d{4}","\\d{7}"]
,[,,"(?:25\\d|4(?:2[12389]|9\\d)|7\\d{2}|87[15-7]|9[1-8]\\d)\\d{4}","\\d{7}"]
,[,,"(?:2(?:[034789]\\d|1[0-7])|4(?:[013-8]\\d|2[4-7])|[56]\\d{2}|8(?:14|3[129]))\\d{4}","\\d{7}"]
,[,,"(?:25\\d|4(?:2[12389]|9\\d)|7\\d{2}|87[15-8]|9[1-8]\\d)\\d{4}","\\d{7}"]
,[,,"80[012]\\d{4}","\\d{7}"]
,[,,"30\\d{5}","\\d{7}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"3(?:20|9\\d)\\d{4}","\\d{7}"]
,"MU",230,"0(?:[2-7]0|33)",,,,,,"020",,[[,"([2-9]\\d{2})(\\d{4})","$1 $2",,"",""]
]
,,[,,"NA","NA"]
,,[,,"2(?:1[89]|2\\d)\\d{4}","\\d{7}"]
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
@ -3186,15 +3194,17 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,"PE":[,[,,"[14-9]\\d{7,8}","\\d{6,9}"]
,[,,"(?:1\\d|4[1-4]|5[1-46]|6[1-7]|7[2-46]|8[2-4])\\d{6}","\\d{6,8}"]
,[,,"9\\d{8}","\\d{9}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"800\\d{5}","\\d{8}"]
,[,,"805\\d{5}","\\d{8}"]
,[,,"801\\d{5}","\\d{8}"]
,[,,"80[24]\\d{5}","\\d{8}"]
,[,,"NA","NA"]
,"PE",51,"19(?:1[124]|77|90)00","0"," Anexo ",,"0",,,,[[,"(1)(\\d{7})","$1 $2",["1"]
,"($1)",""]
,[,"([4-8]\\d)(\\d{6})","$1 $2",["[4-8]"]
,"($1)",""]
,"(0$1)",""]
,[,"([4-8]\\d)(\\d{6})","$1 $2",["[4-7]|8[2-4]"]
,"(0$1)",""]
,[,"(\\d{3})(\\d{5})","$1 $2",["80"]
,"(0$1)",""]
,[,"(9\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"]
,"$1",""]
]
@ -3204,7 +3214,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
]
,"PF":[,[,,"[2-9]\\d{5}","\\d{6}"]
,[,,"(?:36\\d|4(?:[02-9]\\d|1[02-9])|[5689]\\d{2})\\d{3}","\\d{6}"]
,[,,"(?:[27]\\d{3}|3[0-49]\\d{2}|411[3-6])\\d{2}","\\d{6}"]
,[,,"(?:[27]\\d{3}|3[0-59]\\d{2}|411[3-6])\\d{2}","\\d{6}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
@ -3306,15 +3316,17 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"PM":[,[]
,[]
,[]
,"PM":[,[,,"[45]\\d{5}","\\d{6}"]
,[,,"41\\d{4}","\\d{6}"]
,[,,"55\\d{4}","\\d{6}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"PM",508,"00","0",,,"0",,,1,,,[,,"NA","NA"]
,"PM",508,"00","0",,,"0",,,,[[,"([45]\\d)(\\d{2})(\\d{2})","$1 $2 $3",,"0$1",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
@ -3486,23 +3498,25 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,1,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"RW":[,[,,"[27-9]\\d{8}","\\d{9}"]
,[,,"25\\d{7}","\\d{9}"]
,"RW":[,[,,"[027-9]\\d{7,8}","\\d{8,9}"]
,[,,"2[258]\\d{7}|06\\d{6}","\\d{8,9}"]
,[,,"7[258]\\d{7}","\\d{9}"]
,[,,"800\\d{6}","\\d{9}"]
,[,,"900\\d{6}","\\d{9}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"RW",250,"000","0",,,"0",,,,[[,"(25\\d)(\\d{3})(\\d{3})","$1 $2 $3",["2"]
,"RW",250,"00","0",,,"0",,,,[[,"(2\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"]
,"$1",""]
,[,"([7-9]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"]
,"0$1",""]
,[,"(0\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"]
,"",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,1]
,"SA":[,[,,"[1-9]\\d{7,10}","\\d{7,11}"]
,[,,"(?:1[24-7]|2[24-8]|3[35-8]|4[34-68]|6[2-5]|7[235-7])\\d{6}","\\d{7,8}"]
,[,,"(?:5[013-69]\\d|8111)\\d{6}","\\d{9,10}"]
@ -3538,17 +3552,17 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"SC":[,[,,"[2-8]\\d{5,6}","\\d{6,7}"]
,[,,"(?:2?(?:55[0-5]|78[013])|4?(?:2(?:1[78]|2[14-69]|3[2-4]|4[1-36-8]|6[167]|[89]\\d)|3(?:0[34]|2[1-6]|4[4-6]|55|6[016]|7\\d|8[0-589]|9[0-5])|6(?:0[0-256]|1[0-478]|2[145]|3[02-4]|4[124]|6[015]|7\\d|8[1-3])))\\d{3}","\\d{6,7}"]
,"SC":[,[,,"[2-9]\\d{5,6}","\\d{6,7}"]
,[,,"(?:2?(?:55[0-5]|78[013])|4?(?:2(?:0[589]|1[03-9]|[2-9]\\d)|[36]\\d{2})|44\\d{2})\\d{3}","\\d{6,7}"]
,[,,"2?(?:5(?:[0-46-9]\\d|5[6-9])|7(?:[0-79]\\d|8[24-9]))\\d{3}","\\d{6,7}"]
,[,,"8000\\d{2}","\\d{6}"]
,[,,"98\\d{4}","\\d{6}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"(?:44[1-3]|647)\\d{4}","\\d{7}"]
,"SC",248,"0[0-2]",,,,,,"00",,[[,"(\\d{3})(\\d{3})","$1 $2",["[3578]|2[1-4689]|6(?:[0-35-9]|4[0-689])"]
,[,,"64\\d{5}","\\d{7}"]
,"SC",248,"0[0-2]",,,,,,"00",,[[,"(\\d{3})(\\d{3})","$1 $2",["[35789]|2[1-4689]|6[0-35-9]"]
,"",""]
,[,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["2[57]|4[2-46]|647"]
,[,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["2[57]|4|64"]
,"",""]
]
,,[,,"NA","NA"]
@ -3824,7 +3838,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
]
,"SY":[,[,,"[1-59]\\d{7,8}","\\d{6,9}"]
,[,,"(?:1(?:1\\d?|4\\d|[2356])|2[1-35]|3(?:1\\d|[34])|4[13]|5[1-3])\\d{6}","\\d{6,9}"]
,[,,"(?:1(?:1\\d?|4\\d|[2356])|2[1-35]|3(?:[13]\\d|4)|4[13]|5[1-3])\\d{6}","\\d{6,9}"]
,[,,"9(?:3[23]|4[457]|55|6[67]|88|9[1-49])\\d{6}","\\d{9}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
@ -3893,15 +3907,16 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"TG":[,[,,"[02-9]\\d{6}","\\d{7}"]
,[,,"(?:2[2-7]|3[23]|44|55|66|77)\\d{5}","\\d{7}"]
,[,,"(?:0[1-9]|7[56]|8[1-7]|9\\d)\\d{5}","\\d{7}"]
,"TG":[,[,,"[02-9]\\d{6,7}","\\d{7,8}"]
,[,,"2?(?:2[2-7]|3[23]|44|55|66|77)\\d{5}","\\d{7,8}"]
,[,,"(?:0[1-9]|7[56]|8[1-7]|9\\d)\\d{5}|9[0-289]\\d{6}","\\d{7,8}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"TG",228,"00",,,,,,,,[[,"(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",,"",""]
,[,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",,"",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
@ -3938,7 +3953,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
,"TJ",992,"8~10","8",,,"8",,,,[[,"([349]\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[34]7|91[78]"]
,"(8) $1",""]
,[,"([459]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[48]|5|9(?:19|[0235-9])"]
,[,"([459]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[48]|5|9(?:1[59]|[0235-9])"]
,"(8) $1",""]
,[,"(331700)(\\d)(\\d{2})","$1 $2 $3",["331","3317","33170","331700"]
,"(8) $1",""]
@ -3949,9 +3964,9 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"TK":[,[]
,[]
,[]
,"TK":[,[,,"[1-9]\\d{3}","\\d{4}"]
,[,,"[1-9]\\d{3}","\\d{4}"]
,[,,"[1-9]\\d{3}","\\d{4}"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
@ -4147,8 +4162,8 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
,[,,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}"]
,[,,"NA","NA"]
,"US",1,"011","1",,,"1",,,1,[[,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",,"",""]
,[,"(\\d{3})(\\d{4})","$1-$2",,"",""]
,"US",1,"011","1",,,"1",,,1,[[,"(\\d{3})(\\d{4})","$1-$2",,"",""]
,[,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",,"",""]
]
,[[,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3"]
]
@ -4282,7 +4297,7 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,"NA","NA"]
,[,,"NA","NA"]
]
,"VU":[,[,,"[2-578]\\d{4,6}","\\d{5,7}"]
,"VU":[,[,,"[2-57-9]\\d{4,6}","\\d{5,7}"]
,[,,"(?:2[2-9]\\d|3(?:[67]\\d|8[0-8])|48[4-9]|88\\d)\\d{2}","\\d{5}"]
,[,,"(?:5(?:7[2-5]|[3-69]\\d)|7[013-7]\\d)\\d{4}","\\d{7}"]
,[,,"NA","NA"]
@ -4290,12 +4305,12 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,[,,"NA","NA"]
,[,,"NA","NA"]
,[,,"NA","NA"]
,"VU",678,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2",["[57]"]
,"VU",678,"00",,,,,,,,[[,"(\\d{3})(\\d{4})","$1 $2",["[579]"]
,"",""]
]
,,[,,"NA","NA"]
,,,[,,"NA","NA"]
,[,,"30\\d{3}","\\d{5}"]
,[,,"30\\d{3}|900\\d{4}","\\d{5,7}"]
]
,"WF":[,[,,"[5-7]\\d{5}","\\d{6}"]
,[,,"(?:50|68|72)\\d{4}","\\d{6}"]


+ 79
- 75
javascript/i18n/phonenumbers/phonenumberutil.js View File

@ -20,6 +20,12 @@
* Functionality includes formatting, parsing and validation.
* (based on the java implementation).
*
* NOTE: A lot of methods in this class require Region Code strings. These must
* be provided using ISO 3166-1 two-letter country-code format. These should be
* in upper-case (but for compatibility lower-case is also allowed). The list of
* the codes can be found here:
* http://www.iso.org/iso/english_country_names_and_code_elements
*
* @author Nikolaos Trogkanis
*/
@ -426,7 +432,8 @@ i18n.phonenumbers.PhoneNumberUtil.UNIQUE_INTERNATIONAL_PREFIX_ =
* excludes punctuation found as a leading character only. This consists of dash
* characters, white space characters, full stops, slashes, square brackets,
* parentheses and tildes. It also includes the letter 'x' as that is found as a
* placeholder for carrier information in some phone numbers.
* placeholder for carrier information in some phone numbers. Full-width
* variants are also present.
*
* @const
* @type {string}
@ -705,13 +712,13 @@ i18n.phonenumbers.PhoneNumberUtil.CC_PATTERN_ = /\$CC/;
/**
* INTERNATIONAL and NATIONAL formats are consistent with the definition in
* ITU-T Recommendation E. 123. For example, the number of the Google Zurich
* office will be written as '+41 44 668 1800' in INTERNATIONAL format, and as
* '044 668 1800' in NATIONAL format. E164 format is as per INTERNATIONAL format
* but with no formatting applied, e.g. +41446681800. RFC3966 is as per
* INTERNATIONAL format, but with all spaces and other separating symbols
* replaced with a hyphen, and with any phone number extension appended with
* ';ext='.
* ITU-T Recommendation E. 123. For example, the number of the Google
* Switzerland office will be written as '+41 44 668 1800' in INTERNATIONAL
* format, and as '044 668 1800' in NATIONAL format. E164 format is as per
* INTERNATIONAL format but with no formatting applied, e.g. +41446681800.
* RFC3966 is as per INTERNATIONAL format, but with all spaces and other
* separating symbols replaced with a hyphen, and with any phone number
* extension appended with ';ext='.
*
* Note: If you are considering storing the number in a neutral format, you are
* highly advised to use the PhoneNumber class.
@ -856,13 +863,16 @@ i18n.phonenumbers.PhoneNumberUtil.isViablePhoneNumber = function(number) {
/**
* Normalizes a string of characters representing a phone number. This performs
* the following conversions:
* - Wide-ascii digits are converted to normal ASCII (European) digits.
* - Letters are converted to their numeric representation on a telephone
* keypad. The keypad used here is the one defined in ITU Recommendation E.161.
* This is only done if there are 3 or more letters in the number, to lessen the
* risk that such letters are typos - otherwise alpha characters are stripped.
* - Punctuation is stripped.
* - Arabic-Indic numerals are converted to European numerals.
* Punctuation is stripped.
* For ALPHA/VANITY numbers:
* Letters are converted to their numeric representation on a telephone
* keypad. The keypad used here is the one defined in ITU Recommendation
* E.161. This is only done if there are 3 or more letters in the number,
* to lessen the risk that such letters are typos.
* For other numbers:
* Wide-ascii digits are converted to normal ASCII (European) digits.
* Arabic-Indic numerals are converted to European numerals.
* Spurious alpha characters are stripped.
*
* @param {string} number a string of characters representing a phone number.
* @return {string} the normalized string version of the phone number.
@ -873,8 +883,7 @@ i18n.phonenumbers.PhoneNumberUtil.normalize = function(number) {
return i18n.phonenumbers.PhoneNumberUtil.normalizeHelper_(number,
i18n.phonenumbers.PhoneNumberUtil.ALL_NORMALIZATION_MAPPINGS_, true);
} else {
return i18n.phonenumbers.PhoneNumberUtil.normalizeHelper_(number,
i18n.phonenumbers.PhoneNumberUtil.DIGIT_MAPPINGS, true);
return i18n.phonenumbers.PhoneNumberUtil.normalizeDigitsOnly(number);
}
};
@ -954,17 +963,19 @@ i18n.phonenumbers.PhoneNumberUtil.convertAlphaCharactersInNumber =
* </pre>
*
* N.B.: area code is a very ambiguous concept, so the I18N team generally
* recommends against using it for most purposes. Read the following carefully
* before deciding to use this method:
*
* - geographical area codes change over time, and this method honors those
* changes; therefore, it doesn't guarantee the stability of the result it
* produces.
* - subscriber numbers may not be diallable from all devices (notably mobile
* devices, which typically requires the full national_number to be dialled in
* most countries).
* - most non-geographical numbers have no area codes.
* - some geographical numbers have no area codes.
* recommends against using it for most purposes, but recommends using the more
* general {@code national_number} instead. Read the following carefully before
* deciding to use this method:
* <ul>
* <li> geographical area codes change over time, and this method honors those
* changes; therefore, it doesn't guarantee the stability of the result it
* produces.
* <li> subscriber numbers may not be diallable from all devices (notably
* mobile devices, which typically requires the full national_number to be
* dialled in most regions).
* <li> most non-geographical numbers have no area codes.
* <li> some geographical numbers have no area codes.
* </ul>
*
* @param {i18n.phonenumbers.PhoneNumber} number the PhoneNumber object for
* which clients want to know the length of the area code.
@ -1162,13 +1173,13 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.format =
function(number, numberFormat) {
/** @type {number} */
var countryCode = number.getCountryCodeOrDefault();
var countryCallingCode = number.getCountryCodeOrDefault();
/** @type {string} */
var nationalSignificantNumber = this.getNationalSignificantNumber(number);
if (numberFormat == i18n.phonenumbers.PhoneNumberFormat.E164) {
// Early exit for E164 case since no formatting of the national number needs
// to be applied. Extensions are not formatted.
return this.formatNumberByFormat_(countryCode,
return this.formatNumberByFormat_(countryCallingCode,
i18n.phonenumbers.PhoneNumberFormat.E164,
nationalSignificantNumber, '');
}
@ -1177,7 +1188,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.format =
// region for performance reasons. For example, for NANPA regions it will be
// contained in the metadata for US.
/** @type {string} */
var regionCode = this.getRegionCodeForCountryCode(countryCode);
var regionCode = this.getRegionCodeForCountryCode(countryCallingCode);
if (!this.isValidRegionCode_(regionCode)) {
return nationalSignificantNumber;
}
@ -1190,7 +1201,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.format =
this.formatNationalNumber_(nationalSignificantNumber,
regionCode,
numberFormat);
return this.formatNumberByFormat_(countryCode,
return this.formatNumberByFormat_(countryCallingCode,
numberFormat,
formattedNationalNumber,
formattedExtension);
@ -1364,8 +1375,8 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.
/**
* Formats a phone number for out-of-country dialing purposes. If no
* regionCallingFrom is supplied, we format the number in its INTERNATIONAL
* format. If the country calling code is the same as the region where the
* number is from, then NATIONAL formatting will be applied.
* format. If the country calling code is the same as that of the region where
* the number is from, then NATIONAL formatting will be applied.
*
* <p>If the number itself has a country calling code of zero or an otherwise
* invalid country calling code, then we return the number with no formatting
@ -1379,8 +1390,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.
*
* @param {i18n.phonenumbers.PhoneNumber} number the phone number to be
* formatted.
* @param {string} regionCallingFrom the ISO 3166-1 two-letter region code
* that denotes the region where the call is being placed.
* @param {string} regionCallingFrom the region where the call is being placed.
* @return {string} the formatted phone number.
*/
i18n.phonenumbers.PhoneNumberUtil.prototype.formatOutOfCountryCallingNumber =
@ -1613,8 +1623,8 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.
* Gets the national significant number of the a phone number. Note a national
* significant number doesn't contain a national prefix or any formatting.
*
* @param {i18n.phonenumbers.PhoneNumber} number the PhoneNumber object for
* which the national significant number is needed.
* @param {i18n.phonenumbers.PhoneNumber} number the phone number for which the
* national significant number is needed.
* @return {string} the national significant number of the PhoneNumber object
* passed in.
*/
@ -1790,8 +1800,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.formatAccordingToFormats_ =
/**
* Gets a valid number for the specified region.
*
* @param {string} regionCode the ISO 3166-1 two-letter region code that
* denotes the region for which an example number is needed.
* @param {string} regionCode the region for which an example number is needed.
* @return {i18n.phonenumbers.PhoneNumber} a valid fixed-line number for the
* specified region. Returns null when the metadata does not contain such
* information.
@ -1807,13 +1816,12 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.getExampleNumber =
/**
* Gets a valid number for the specified region and number type.
*
* @param {string} regionCode the ISO 3166-1 two-letter region code that
* denotes the region for which an example number is needed.
* @param {string} regionCode the region for which an example number is needed.
* @param {i18n.phonenumbers.PhoneNumberType} type the type of number that is
* needed.
* @return {i18n.phonenumbers.PhoneNumber} a valid number for the specified
* region and type. Returns null when the metadata does not contain such
* information.
* information or if an invalid region was entered.
*/
i18n.phonenumbers.PhoneNumberUtil.prototype.getExampleNumberForType =
function(regionCode, type) {
@ -2080,8 +2088,8 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.isValidNumber = function(number) {
*
* @param {i18n.phonenumbers.PhoneNumber} number the phone number that we want
* to validate.
* @param {string} regionCode the ISO 3166-1 two-letter region code that
* denotes the region that we want to validate the phone number for.
* @param {string} regionCode the region that we want to validate the phone
* number for.
* @return {boolean} a boolean that indicates whether the number is of a valid
* pattern.
*/
@ -2203,8 +2211,8 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.getRegionCodeForCountryCode =
* Returns the country calling code for a specific region. For example, this
* would be 1 for the United States, and 64 for New Zealand.
*
* @param {?string} regionCode the ISO 3166-1 two-letter region code that
* denotes the region that we want to get the country calling code for.
* @param {?string} regionCode the region that we want to get the country
* calling code for.
* @return {number} the country calling code for the region denoted by
* regionCode.
*/
@ -2232,8 +2240,8 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.getCountryCodeForRegion =
* numbers. Use the library's formatting functions to prefix the national prefix
* when required.
*
* @param {?string} regionCode the ISO 3166-1 two-letter region code that
* denotes the region that we want to get the dialling prefix for.
* @param {?string} regionCode the region that we want to get the dialling
* prefix for.
* @param {boolean} stripNonDigits true to strip non-digits from the national
* dialling prefix.
* @return {?string} the dialling prefix for the region denoted by
@ -2265,13 +2273,13 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.getNddPrefixForRegion = function(
* Checks if this is a region under the North American Numbering Plan
* Administration (NANPA).
*
* @param {string} regionCode the ISO 3166-1 two-letter region code.
* @param {?string} regionCode the ISO 3166-1 two-letter region code.
* @return {boolean} true if regionCode is one of the regions under NANPA.
*/
i18n.phonenumbers.PhoneNumberUtil.prototype.isNANPACountry =
function(regionCode) {
return goog.array.contains(
return regionCode != null && goog.array.contains(
i18n.phonenumbers.metadata.countryCodeToRegionCodeMap[
i18n.phonenumbers.PhoneNumberUtil.NANPA_COUNTRY_CODE_],
regionCode.toUpperCase());
@ -2441,8 +2449,8 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.isPossibleNumberWithReason =
*
* @param {string} number the number that needs to be checked, in the form of a
* string.
* @param {string} regionDialingFrom the ISO 3166-1 two-letter region code that
* denotes the region that we are expecting the number to be dialed from.
* @param {string} regionDialingFrom the region that we are expecting the number
* to be dialed from.
* Note this is different from the region where the number belongs.
* For example, the number +1 650 253 0000 is a number that belongs to US.
* When written in this form, it can be dialed from any region. When it is
@ -2690,9 +2698,8 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.parsePrefixAsIdd_ =
if (matchedGroups && matchedGroups[1] != null &&
matchedGroups[1].length > 0) {
/** @type {string} */
var normalizedGroup = i18n.phonenumbers.PhoneNumberUtil.normalizeHelper_(
matchedGroups[1], i18n.phonenumbers.PhoneNumberUtil.DIGIT_MAPPINGS,
true);
var normalizedGroup = i18n.phonenumbers.PhoneNumberUtil.normalizeDigitsOnly(
matchedGroups[1]);
if (normalizedGroup == '0') {
return false;
}
@ -2871,8 +2878,8 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.maybeStripExtension =
* the number to parse starts with a + symbol so that we can attempt to infer
* the region from the number.
* @param {string} numberToParse number that we are attempting to parse.
* @param {?string} defaultRegion the ISO 3166-1 two-letter region code that
* denotes the region that we are expecting the number to be from.
* @param {?string} defaultRegion region that we are expecting the number to be
* from.
* @return {boolean} false if it cannot use the region provided and the region
* cannot be inferred.
* @private
@ -2897,13 +2904,12 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.checkRegionForParsing_ = function(
* @param {?string} numberToParse number that we are attempting to parse. This
* can contain formatting such as +, ( and -, as well as a phone number
* extension.
* @param {?string} defaultRegion the ISO 3166-1 two-letter region code that
* denotes the region that we are expecting the number to be from. This is
* only used if the number being parsed is not written in international
* format. The country_code for the number in this case would be stored as
* that of the default region supplied. If the number is guaranteed to start
* with a '+' followed by the country calling code, then 'ZZ' or null can be
* supplied.
* @param {?string} defaultRegion region that we are expecting the number to be
* from. This is only used if the number being parsed is not written in
* international format. The country_code for the number in this case would
* be stored as that of the default region supplied. If the number is
* guaranteed to start with a '+' followed by the country calling code, then
* 'ZZ' or null can be supplied.
* @return {i18n.phonenumbers.PhoneNumber} a phone number proto buffer filled
* with the parsed number.
* @throws {i18n.phonenumbers.Error} if the string is not considered to be a
@ -2924,11 +2930,10 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.parse = function(numberToParse,
* @param {string} numberToParse number that we are attempting to parse. This
* can contain formatting such as +, ( and -, as well as a phone number
* extension.
* @param {?string} defaultRegion the ISO 3166-1 two-letter region code that
* denotes the region that we are expecting the number to be from. This is
* only used if the number being parsed is not written in international
* format. The country calling code for the number in this case would be
* stored as that of the default region supplied.
* @param {?string} defaultRegion region that we are expecting the number to be
* from. This is only used if the number being parsed is not written in
* international format. The country calling code for the number in this
* case would be stored as that of the default region supplied.
* @return {i18n.phonenumbers.PhoneNumber} a phone number proto buffer filled
* with the parsed number.
* @throws {i18n.phonenumbers.Error} if the string is not considered to be a
@ -2955,11 +2960,10 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.parseAndKeepRawInput =
* @param {?string} numberToParse number that we are attempting to parse. This
* can contain formatting such as +, ( and -, as well as a phone number
* extension.
* @param {?string} defaultRegion the ISO 3166-1 two-letter region code that
* denotes the region that we are expecting the number to be from. This is
* only used if the number being parsed is not written in international
* format. The country calling code for the number in this case would be
* stored as that of the default region supplied.
* @param {?string} defaultRegion region that we are expecting the number to be
* from. This is only used if the number being parsed is not written in
* international format. The country calling code for the number in this
* case would be stored as that of the default region supplied.
* @param {boolean} keepRawInput whether to populate the raw_input field of the
* phoneNumber with numberToParse.
* @param {boolean} checkRegion should be set to false if it is permitted for


+ 29
- 8
javascript/i18n/phonenumbers/phonenumberutil_test.js View File

@ -215,8 +215,8 @@ function testGetInstanceLoadUSMetadata() {
assertTrue(metadata.hasNationalPrefix());
assertEquals(2, metadata.numberFormatCount());
assertEquals('(\\d{3})(\\d{3})(\\d{4})',
metadata.getNumberFormat(0).getPattern());
assertEquals('$1 $2 $3', metadata.getNumberFormat(0).getFormat());
metadata.getNumberFormat(1).getPattern());
assertEquals('$1 $2 $3', metadata.getNumberFormat(1).getFormat());
assertEquals('[13-9]\\d{9}|2[0-35-9]\\d{8}',
metadata.getGeneralDesc().getNationalNumberPattern());
assertEquals('\\d{7}(?:\\d{3})?',
@ -374,6 +374,16 @@ function testGetExampleNumber() {
assertNull(phoneUtil.getExampleNumberForType(RegionCode.CS, PNT.MOBILE));
}
function testConvertAlphaCharactersInNumber() {
/** @type {string} */
var input = '1800-ABC-DEF';
// Alpha chars are converted to digits; everything else is left untouched.
/** @type {string} */
var expectedOutput = '1800-222-333';
assertEquals(expectedOutput,
i18n.phonenumbers.PhoneNumberUtil.convertAlphaCharactersInNumber(input));
}
function testNormaliseRemovePunctuation() {
/** @type {string} */
var inputNumber = '034-56&+#234';
@ -1073,7 +1083,6 @@ function testIsValidForRegion() {
// This number is valid for the Bahamas, but is not a valid US number.
assertTrue(phoneUtil.isValidNumber(BS_NUMBER));
assertTrue(phoneUtil.isValidNumberForRegion(BS_NUMBER, RegionCode.BS));
assertTrue(phoneUtil.isValidNumberForRegion(BS_NUMBER, 'bs'));
assertFalse(phoneUtil.isValidNumberForRegion(BS_NUMBER, RegionCode.US));
/** @type {i18n.phonenumbers.PhoneNumber} */
var bsInvalidNumber = new i18n.phonenumbers.PhoneNumber();
@ -1149,7 +1158,6 @@ function testGetRegionCodeForNumber() {
function testGetCountryCodeForRegion() {
assertEquals(1, phoneUtil.getCountryCodeForRegion(RegionCode.US));
assertEquals(64, phoneUtil.getCountryCodeForRegion(RegionCode.NZ));
assertEquals(64, phoneUtil.getCountryCodeForRegion('nz'));
assertEquals(0, phoneUtil.getCountryCodeForRegion(null));
assertEquals(0, phoneUtil.getCountryCodeForRegion(RegionCode.ZZ));
// CS is already deprecated so the library doesn't support it.
@ -1175,7 +1183,9 @@ function testGetNationalDiallingPrefixForRegion() {
function testIsNANPACountry() {
assertTrue(phoneUtil.isNANPACountry(RegionCode.US));
assertTrue(phoneUtil.isNANPACountry(RegionCode.BS));
assertTrue(phoneUtil.isNANPACountry('bs'));
assertFalse(phoneUtil.isNANPACountry(RegionCode.DE));
assertFalse(phoneUtil.isNANPACountry(RegionCode.ZZ));
assertFalse(phoneUtil.isNANPACountry(null));
}
function testIsPossibleNumber() {
@ -1201,8 +1211,6 @@ function testIsPossibleNumber() {
phoneUtil.isPossibleNumberString('7031 3000', RegionCode.GB));
assertTrue(
phoneUtil.isPossibleNumberString('3331 6005', RegionCode.NZ));
assertTrue(
phoneUtil.isPossibleNumberString('3331 6005', 'nz'));
}
function testIsPossibleNumberWithReason() {
@ -1354,6 +1362,10 @@ function testIsViablePhoneNumber() {
// Alpha numbers.
assertTrue(isViable('0800-4-pizza'));
assertTrue(isViable('0800-4-PIZZA'));
}
function testIsViablePhoneNumberNonAscii() {
var isViable = i18n.phonenumbers.PhoneNumberUtil.isViablePhoneNumber;
// Only one or two digits before possible punctuation followed by more digits.
assertTrue(isViable('1\u300034'));
assertFalse(isViable('1\u30003+4'));
@ -1655,7 +1667,6 @@ function testMaybeExtractCountryCode() {
function testParseNationalNumber() {
// National prefix attached.
assertTrue(NZ_NUMBER.equals(phoneUtil.parse('033316005', RegionCode.NZ)));
assertTrue(NZ_NUMBER.equals(phoneUtil.parse('033316005', 'nz')));
assertTrue(NZ_NUMBER.equals(phoneUtil.parse('33316005', RegionCode.NZ)));
// National prefix attached and some formatting present.
assertTrue(NZ_NUMBER.equals(phoneUtil.parse('03-331 6005', RegionCode.NZ)));
@ -1736,6 +1747,9 @@ function testParseWithInternationalPrefixes() {
// Using '++' at the start.
assertTrue(US_NUMBER.equals(
phoneUtil.parse('++1 (650) 253-0000', RegionCode.PL)));
}
function testParseNonAscii() {
// Using a full-width plus sign.
assertTrue(US_NUMBER.equals(
phoneUtil.parse('\uFF0B1 (650) 253-0000', RegionCode.SG)));
@ -1750,6 +1764,13 @@ function testParseWithInternationalPrefixes() {
phoneUtil.parse('\uFF0B\uFF11\u3000\uFF08\uFF16\uFF15\uFF10\uFF09' +
'\u3000\uFF12\uFF15\uFF13\u30FC\uFF10\uFF10\uFF10\uFF10',
RegionCode.SG)));
// Using a very strange decimal digit range (Mongolian digits).
// TODO(user): Support Mongolian digits
// assertTrue(US_NUMBER.equals(
// phoneUtil.parse('\u1811 \u1816\u1815\u1810 ' +
// '\u1812\u1815\u1813 \u1810\u1810\u1810\u1810',
// RegionCode.US)));
}
function testParseWithLeadingZero() {


Loading…
Cancel
Save