From 3f782e75b84803e16e2fe7c3f1ffe3ec671a4e69 Mon Sep 17 00:00:00 2001 From: Shaopeng Jia Date: Thu, 21 Apr 2011 07:46:19 +0000 Subject: [PATCH] JAVA: libphonenumber v3.3. --- java/release_notes.txt | 10 + .../i18n/phonenumbers/AsYouTypeFormatter.java | 33 +- .../i18n/phonenumbers/PhoneNumberMatcher.java | 85 ++- .../i18n/phonenumbers/PhoneNumberUtil.java | 63 +-- .../data/PhoneNumberMetadataProto_AM | Bin 524 -> 582 bytes .../data/PhoneNumberMetadataProto_AZ | Bin 737 -> 819 bytes .../data/PhoneNumberMetadataProto_BF | Bin 384 -> 384 bytes .../data/PhoneNumberMetadataProto_BW | Bin 516 -> 568 bytes .../data/PhoneNumberMetadataProto_BZ | Bin 386 -> 380 bytes .../data/PhoneNumberMetadataProto_CI | Bin 381 -> 384 bytes .../data/PhoneNumberMetadataProto_CR | Bin 420 -> 433 bytes .../data/PhoneNumberMetadataProto_FJ | Bin 147 -> 396 bytes .../data/PhoneNumberMetadataProto_FM | Bin 147 -> 297 bytes .../data/PhoneNumberMetadataProto_GB | Bin 2743 -> 2743 bytes .../data/PhoneNumberMetadataProto_GP | Bin 374 -> 390 bytes .../data/PhoneNumberMetadataProto_GY | Bin 154 -> 397 bytes .../data/PhoneNumberMetadataProto_HK | Bin 471 -> 481 bytes .../data/PhoneNumberMetadataProto_JM | Bin 545 -> 552 bytes .../data/PhoneNumberMetadataProto_KH | Bin 505 -> 515 bytes .../data/PhoneNumberMetadataProto_LB | Bin 488 -> 494 bytes .../data/PhoneNumberMetadataProto_LY | Bin 311 -> 309 bytes .../data/PhoneNumberMetadataProto_MV | Bin 466 -> 465 bytes .../data/PhoneNumberMetadataProto_NF | Bin 147 -> 318 bytes .../data/PhoneNumberMetadataProto_NI | Bin 153 -> 272 bytes .../data/PhoneNumberMetadataProto_NR | Bin 153 -> 266 bytes .../data/PhoneNumberMetadataProto_PE | Bin 416 -> 434 bytes .../data/PhoneNumberMetadataProto_PK | Bin 1725 -> 1725 bytes .../data/PhoneNumberMetadataProto_SZ | Bin 495 -> 417 bytes .../data/PhoneNumberMetadataProto_TJ | Bin 587 -> 616 bytes .../data/PhoneNumberMetadataProto_TV | Bin 147 -> 221 bytes .../data/PhoneNumberMetadataProto_US | Bin 1601 -> 1605 bytes .../phonenumbers/AsYouTypeFormatterTest.java | 2 +- .../phonenumbers/PhoneNumberMatcherTest.java | 26 +- .../phonenumbers/PhoneNumberUtilTest.java | 8 +- .../PhoneNumberMetadataProtoForTesting_JP | Bin 436 -> 469 bytes resources/PhoneNumberMetaData.xml | 491 +++++++++++++++--- resources/PhoneNumberMetaDataForTesting.xml | 6 + 37 files changed, 549 insertions(+), 175 deletions(-) diff --git a/java/release_notes.txt b/java/release_notes.txt index 5784e0ed8..c6a9d97eb 100644 --- a/java/release_notes.txt +++ b/java/release_notes.txt @@ -1,3 +1,13 @@ +Apr 26th, 2011 +* Code changes: + - Improved PhoneNumberMatcher for cases with other numbers before or after the phone number. + - Improved AsYouTypeFormatter not to use formatting rules containing non-formatting characters + (e.g. '*' in Israeli star numbers). +* Metadata changes: + - New countries: FJ, FM, GY, NF, NI, NR, TV. + - Updates: AM, AZ, BF, BW, BZ, CI, CR, GB, GP, HK, JM, KH, LB, LY, MV, PE, PK, SZ, TJ, US. +* Minor documentation updates + Apr 11th, 2011 * Bug fixes: - Adding date exclusion pattern in PhoneNumberMatcher. diff --git a/java/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java b/java/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java index 1dac89a1a..0080de93c 100644 --- a/java/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java +++ b/java/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java @@ -28,11 +28,11 @@ import java.util.regex.Pattern; /** * A formatter which formats phone numbers as they are entered. * - *

An AsYouTypeFormatter could be created by invoking - * {@link PhoneNumberUtil#getAsYouTypeFormatter}. After that digits could be added by invoking + *

An AsYouTypeFormatter can be created by invoking + * {@link PhoneNumberUtil#getAsYouTypeFormatter}. After that, digits can be added by invoking * {@link #inputDigit} on the formatter instance, and the partially formatted phone number will be - * returned each time a digit is added. {@link #clear} could be invoked before a new number needs to - * be formatted. + * returned each time a digit is added. {@link #clear} can be invoked before formatting a new + * number. * *

See the unittests for more details on how the formatter is to be used. * @@ -66,6 +66,15 @@ public class AsYouTypeFormatter { // the phone number can be as long as 15 digits. private static final Pattern STANDALONE_DIGIT_PATTERN = Pattern.compile("\\d(?=[^,}][^,}])"); + // A pattern that is used to determine if a numberFormat under availableFormats is eligible to be + // used by the AYTF. It is eligible when the format element under numberFormat contains groups of + // the dollar sign followed by a single digit, separated by valid phone number punctuation. This + // prevents invalid punctuation (such as the star sign in Israeli star numbers) getting into the + // output of the AYTF. + private static final Pattern ELIGIBLE_FORMAT_PATTERN = + Pattern.compile("[" + PhoneNumberUtil.VALID_PUNCTUATION + "]*" + + "(\\$\\d" + "[" + PhoneNumberUtil.VALID_PUNCTUATION + "]*)+"); + // This is the minimum length of national number accrued that is required to trigger the // formatter. The first element of the leadingDigitsPattern of each numberFormat contains a // regular expression that matches up to this number of digits. @@ -134,10 +143,18 @@ public class AsYouTypeFormatter { (isInternationalFormatting && currentMetaData.intlNumberFormatSize() > 0) ? currentMetaData.intlNumberFormats() : currentMetaData.numberFormats(); - possibleFormats.addAll(formatList); + for (NumberFormat format : formatList) { + if (isFormatEligible(format.getFormat())) { + possibleFormats.add(format); + } + } narrowDownPossibleFormats(leadingThreeDigits); } + private boolean isFormatEligible(String format) { + return ELIGIBLE_FORMAT_PATTERN.matcher(format).matches(); + } + private void narrowDownPossibleFormats(String leadingDigits) { int indexOfLeadingDigitsPattern = leadingDigits.length() - MIN_LEADING_DIGITS_LENGTH; Iterator it = possibleFormats.iterator(); @@ -179,7 +196,7 @@ public class AsYouTypeFormatter { return false; } - // Gets a formatting template which could be used to efficiently format a partial number where + // Gets a formatting template which can be used to efficiently format a partial number where // digits are added one by one. private String getFormattingTemplate(String numberPattern, String numberFormat) { // Creates a phone number consisting only of the digit 9 that matches the @@ -196,7 +213,7 @@ public class AsYouTypeFormatter { } /** - * Clears the internal state of the formatter, so it could be reused. + * Clears the internal state of the formatter, so it can be reused. */ public void clear() { currentOutput = ""; @@ -234,7 +251,7 @@ public class AsYouTypeFormatter { /** * Same as {@link #inputDigit}, but remembers the position where {@code nextChar} is inserted, so - * that it could be retrieved later by using {@link #getRememberedPosition}. The remembered + * that it can be retrieved later by using {@link #getRememberedPosition}. The remembered * position will be automatically adjusted if additional formatting characters are later * inserted/removed in front of {@code nextChar}. */ diff --git a/java/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java b/java/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java index 09bc51e57..09eb35c4b 100644 --- a/java/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java +++ b/java/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java @@ -53,12 +53,6 @@ final class PhoneNumberMatcher implements Iterator { * */ private static final Pattern PATTERN; - /** - * A phone number pattern that does not allow whitespace as punctuation. This pattern is only used - * in a second attempt to find a phone number occurring in the context of other numbers, such as - * when the preceding or following token is a zip code. - */ - private static final Pattern INNER; /** * Matches strings that look like publication pages. Example: *

Computing Complete Answers to Queries in the Presence of Limited Access Patterns.
@@ -75,9 +69,15 @@ final class PhoneNumberMatcher implements Iterator {
   private static final Pattern SLASH_SEPARATED_DATES =
       Pattern.compile("(?:(?:[0-3]?\\d/[01]?\\d)|(?:[01]?\\d/[0-3]?\\d))/(?:[12]\\d)?\\d{2}");
 
+  /**
+   * Matches white-space, which may indicate the end of a phone number and the start of something
+   * else (such as a neighbouring zip-code).
+   */
+  private static final Pattern GROUP_SEPARATOR = Pattern.compile("\\p{Z}+");
+
   static {
-    /* Builds the PATTERN and INNER regular expression patterns. The building blocks below
-     * exist to make the patterns more easily understood. */
+    /* Builds the PATTERN regular expression. The building blocks below exist to make the pattern
+     * more easily understood. */
 
     /* Limit on the number of leading (plus) characters. */
     String leadLimit = limit(0, 2);
@@ -92,10 +92,6 @@ final class PhoneNumberMatcher implements Iterator {
      * formats use spaces to separate each digit. */
     String blockLimit = limit(0, digitBlockLimit);
 
-    /* Same as {@link PhoneNumberUtil#VALID_PUNCTUATION} but without space characters. */
-    String nonSpacePunctuationChars = removeSpace(PhoneNumberUtil.VALID_PUNCTUATION);
-    /* A punctuation sequence without white space. */
-    String nonSpacePunctuation = "[" + nonSpacePunctuationChars + "]" + punctuationLimit;
     /* A punctuation sequence allowing white space. */
     String punctuation = "[" + PhoneNumberUtil.VALID_PUNCTUATION + "]" + punctuationLimit;
     /* A digits block without punctuation. */
@@ -109,12 +105,6 @@ final class PhoneNumberMatcher implements Iterator {
         digitSequence + "(?:" + punctuation + digitSequence + ")" + blockLimit +
         "(?:" + PhoneNumberUtil.KNOWN_EXTN_PATTERNS + ")?",
         PhoneNumberUtil.REGEX_FLAGS);
-
-    /* Phone number pattern with no whitespace allowed. */
-    INNER = Pattern.compile(
-        leadClass + leadLimit +
-        digitSequence + "(?:" + nonSpacePunctuation + digitSequence + ")" + blockLimit,
-        PhoneNumberUtil.REGEX_FLAGS);
   }
 
   /** Returns a regular expression quantifier with an upper and lower limit. */
@@ -125,23 +115,6 @@ final class PhoneNumberMatcher implements Iterator {
     return "{" + lower + "," + upper + "}";
   }
 
-  /**
-   * Returns a copy of {@code characters} with any {@linkplain Character#isSpaceChar space}
-   * characters removed.
-   */
-  private static String removeSpace(String characters) {
-    StringBuilder builder = new StringBuilder(characters.length());
-    int i = 0;
-    while (i < characters.length()) {
-      int codePoint = characters.codePointAt(i);
-      if (!Character.isSpaceChar(codePoint)) {
-        builder.appendCodePoint(codePoint);
-      }
-      i += Character.charCount(codePoint);
-    }
-    return builder.toString();
-  }
-
   /** The potential states of a PhoneNumberMatcher. */
   private enum State {
     NOT_READY, READY, DONE
@@ -287,28 +260,52 @@ final class PhoneNumberMatcher implements Iterator {
       return match;
     }
 
-    // If that failed, try to find an inner match without white space.
+    // If that failed, try to find an "inner match" - there might be a phone number within this
+    // candidate.
     return extractInnerMatch(rawString, offset);
   }
 
   /**
-   * Attempts to extract a match from {@code candidate} using the {@link #INNER} pattern.
+   * Attempts to extract a match from {@code candidate} if the whole candidate does not qualify as a
+   * match.
    *
    * @param candidate  the candidate text that might contain a phone number
-   * @param offset  the offset of {@code candidate} within {@link #text}
+   * @param offset  the current offset of {@code candidate} within {@link #text}
    * @return  the match found, null if none can be found
    */
   private PhoneNumberMatch extractInnerMatch(String candidate, int offset) {
-    int index = 0;
-    Matcher matcher = INNER.matcher(candidate);
-    while ((maxTries > 0) && matcher.find(index)) {
-      String innerCandidate = candidate.substring(matcher.start(), matcher.end());
-      PhoneNumberMatch match = parseAndVerify(innerCandidate, offset + matcher.start());
+    // Try removing either the first or last "group" in the number and see if this gives a result.
+    // We consider white space to be a possible indications of the start or end of the phone number.
+    Matcher groupMatcher = GROUP_SEPARATOR.matcher(candidate);
+
+    if (groupMatcher.find()) {
+      int groupStartIndex = groupMatcher.end();
+      // Remove the first group.
+      CharSequence withoutFirstGroup = candidate.substring(groupStartIndex);
+      withoutFirstGroup = trimAfterFirstMatch(PhoneNumberUtil.UNWANTED_END_CHAR_PATTERN,
+                                              withoutFirstGroup);
+      PhoneNumberMatch match = parseAndVerify(withoutFirstGroup.toString(),
+                                              offset + groupStartIndex);
       if (match != null) {
         return match;
       }
       maxTries--;
-      index = matcher.end();
+
+      if (maxTries > 0) {
+        int lastGroupStart = groupStartIndex;
+        while (groupMatcher.find()) {
+          // Find the last group.
+          lastGroupStart = groupMatcher.start();
+        }
+        CharSequence withoutLastGroup = candidate.substring(0, lastGroupStart);
+        withoutLastGroup = trimAfterFirstMatch(PhoneNumberUtil.UNWANTED_END_CHAR_PATTERN,
+                                               withoutLastGroup);
+        match = parseAndVerify(withoutLastGroup.toString(), offset);
+        if (match != null) {
+          return match;
+        }
+        maxTries--;
+      }
     }
     return null;
   }
diff --git a/java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
index 23c3446f8..db85d88b6 100644
--- a/java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
+++ b/java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
@@ -104,7 +104,8 @@ public class PhoneNumberUtil {
   private static final Map ALL_PLUS_NUMBER_GROUPING_SYMBOLS;
 
   static {
-    // Simple ASCII digits map used to populate DIGIT_MAPPINGS and ALPHA_MAPPINGS.
+    // Simple ASCII digits map used to populate DIGIT_MAPPINGS and
+    // ALL_PLUS_NUMBER_GROUPING_SYMBOLS.
     HashMap asciiDigitMappings = new HashMap();
     asciiDigitMappings.put('0', '0');
     asciiDigitMappings.put('1', '1');
@@ -263,7 +264,7 @@ public class PhoneNumberUtil {
   // are not alpha or numerical characters. The hash character is retained here, as it may signify
   // the previous block was an extension.
   private static final String UNWANTED_END_CHARS = "[[\\P{N}&&\\P{L}]&&[^#]]+$";
-  private static final Pattern UNWANTED_END_CHAR_PATTERN = Pattern.compile(UNWANTED_END_CHARS);
+  static final Pattern UNWANTED_END_CHAR_PATTERN = Pattern.compile(UNWANTED_END_CHARS);
 
   // We use this pattern to check if the phone number has at least three letters in it - if so, then
   // we treat it as a number where some phone-number digits are represented by letters.
@@ -466,13 +467,13 @@ public class PhoneNumberUtil {
 
   /**
    * Attempts to extract a possible number from the string passed in. This currently strips all
-   * leading characters that could not be used to start a phone number. Characters that can be used
-   * to start a phone number are defined in the VALID_START_CHAR_PATTERN. If none of these
-   * characters are found in the number passed in, an empty string is returned. This function also
-   * attempts to strip off any alternative extensions or endings if two or more are present, such as
-   * in the case of: (530) 583-6985 x302/x2303. The second extension here makes this actually two
-   * phone numbers, (530) 583-6985 x302 and (530) 583-6985 x2303. We remove the second extension so
-   * that the first number is parsed correctly.
+   * leading characters that cannot be used to start a phone number. Characters that can be used to
+   * start a phone number are defined in the VALID_START_CHAR_PATTERN. If none of these characters
+   * are found in the number passed in, an empty string is returned. This function also attempts to
+   * strip off any alternative extensions or endings if two or more are present, such as in the case
+   * of: (530) 583-6985 x302/x2303. The second extension here makes this actually two phone numbers,
+   * (530) 583-6985 x302 and (530) 583-6985 x2303. We remove the second extension so that the first
+   * number is parsed correctly.
    *
    * @param number  the string that might contain a phone number
    * @return        the number, stripped of any non-phone-number prefix (such as "Tel:") or an empty
@@ -960,7 +961,7 @@ public class PhoneNumberUtil {
   }
 
   /**
-   * Formats a phone number for out-of-country dialing purposes. If no countryCallingFrom is
+   * 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.
    *
@@ -1624,14 +1625,14 @@ public class PhoneNumberUtil {
    * significant number could contain a leading zero. An example of such a region is Italy. Returns
    * false if no metadata for the country is found.
    */
-   boolean isLeadingZeroPossible(int countryCallingCode) {
-     PhoneMetadata mainMetadataForCallingCode = getMetadataForRegion(
-         getRegionCodeForCountryCode(countryCallingCode));
-     if (mainMetadataForCallingCode == null) {
-       return false;
-     }
-     return mainMetadataForCallingCode.isLeadingZeroPossible();
-   }
+  boolean isLeadingZeroPossible(int countryCallingCode) {
+    PhoneMetadata mainMetadataForCallingCode = getMetadataForRegion(
+        getRegionCodeForCountryCode(countryCallingCode));
+    if (mainMetadataForCallingCode == null) {
+      return false;
+    }
+    return mainMetadataForCallingCode.isLeadingZeroPossible();
+  }
 
   /**
    * Checks if the number is a valid vanity (alpha) number such as 800 MICROSOFT. A valid vanity
@@ -1742,12 +1743,12 @@ public class PhoneNumberUtil {
    * @param number  the number that needs to be checked, in the form of a string
    * @param regionDialingFrom  the ISO 3166-1 two-letter region code that denotes 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 could be
-   *     dialed from any region. When it is written as 00 1 650 253 0000, it could be dialed from
-   *     any region which uses an international dialling prefix of 00. When it is written as 650
-   *     253 0000, it could only be dialed from within the US, and when written as 253 0000, it
-   *     could only be dialed from within a smaller area in the US (Mountain View, CA, to be more
+   *     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 written as 00 1 650 253 0000, it can be dialed from any
+   *     region which uses an international dialling prefix of 00. When it is written as
+   *     650 253 0000, it can only be dialed from within the US, and when written as 253 0000, it
+   *     can only be dialed from within a smaller area in the US (Mountain View, CA, to be more
    *     specific).
    * @return  true if the number is possible
    */
@@ -1791,7 +1792,7 @@ public class PhoneNumberUtil {
    * @param regionCode  the ISO 3166-1 two-letter region code that denotes the region where
    *     the phone number is being entered
    *
-   * @return  an {@link com.google.i18n.phonenumbers.AsYouTypeFormatter} object, which could be used
+   * @return  an {@link com.google.i18n.phonenumbers.AsYouTypeFormatter} object, which can be used
    *     to format phone numbers in the specific region "as you type"
    */
   public AsYouTypeFormatter getAsYouTypeFormatter(String regionCode) {
@@ -1898,8 +1899,8 @@ public class PhoneNumberUtil {
         Pattern possibleNumberPattern =
             regexCache.getPatternForRegex(generalDesc.getPossibleNumberPattern());
         // If the number was not valid before but is valid now, or if it was too long before, we
-        // consider the number with the country code stripped to be a better result and keep that
-        // instead.
+        // consider the number with the country calling code stripped to be a better result and
+        // keep that instead.
         if ((!validNumberPattern.matcher(fullNumber).matches() &&
              validNumberPattern.matcher(potentialNationalNumber).matches()) ||
              testNumberLengthAgainstPattern(possibleNumberPattern, fullNumber.toString())
@@ -1950,8 +1951,8 @@ public class PhoneNumberUtil {
    * @param possibleIddPrefix  the international direct dialing prefix from the region we
    *     think this number may be dialed in
    * @return  the corresponding CountryCodeSource if an international dialing prefix could be
-   *          removed from the number, otherwise CountryCodeSource.FROM_DEFAULT_COUNTRY if the
-   *          number did not seem to be in international format.
+   *     removed from the number, otherwise CountryCodeSource.FROM_DEFAULT_COUNTRY if the number did
+   *     not seem to be in international format.
    */
   CountryCodeSource maybeStripInternationalPrefixAndNormalize(
       StringBuffer number,
@@ -2371,7 +2372,7 @@ public class PhoneNumberUtil {
    * @param firstNumber  first number to compare. Can contain formatting, and can have country
    *     calling code specified with + at the start.
    * @param secondNumber  second number to compare. Can contain formatting, and can have country
-   *     code specified with + at the start.
+   *     calling code specified with + at the start.
    * @return  NOT_A_NUMBER, NO_MATCH, SHORT_NSN_MATCH, NSN_MATCH, EXACT_MATCH. See
    *     isNumberMatch(PhoneNumber firstNumber, PhoneNumber secondNumber) for more details.
    */
@@ -2409,7 +2410,7 @@ public class PhoneNumberUtil {
    *
    * @param firstNumber  first number to compare in proto buffer format.
    * @param secondNumber  second number to compare. Can contain formatting, and can have country
-   *     code specified with + at the start.
+   *     calling code specified with + at the start.
    * @return  NOT_A_NUMBER, NO_MATCH, SHORT_NSN_MATCH, NSN_MATCH, EXACT_MATCH. See
    *     isNumberMatch(PhoneNumber firstNumber, PhoneNumber secondNumber) for more details.
    */
diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AM b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AM
index 45ee014f4fa20aa23329edca7350de2ce747d2c8..62af85daca21f8b4d682ad6b1251b65d58ec8ccf 100644
GIT binary patch
delta 129
zcmeBSImRNk<}Cwj6$1m4Edv7sBO@aNZ?vJVvDrki5HV^t
zW(G#)F)7t1wTuj`K-vOGbAZGQjf_nu>oeLjvP{lrlo98SHZ+d~YqX37s?;!0G1O#a
UU;xQ+Fq$zkFarf9FJ#OH055DCOaK4?

delta 119
zcmX@c(!(OQ<}Cwj6$1kkGXnzyBO@aNZ?vJVvH3)?5?&DvdnoF!XvQ3`NWVrb-qXZ+bj0RY#CWtbctjMG+XvxUHY@lMu2s9c30Dd?Y
AnE(I)

delta 56
zcmdnY_K;O{&07Z6Dh39o8w?B#jEsy7Jkf@_78^wc7$=7?T278-l$hMhD9y;ac_pJK
KBO6c+5C8yvatoIL

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BF b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BF
index a450f514c37d1b65ec070fc4eba10b8eda424c97..63d7e642f9d007eff750a57857e7b5cfc24e603d 100644
GIT binary patch
delta 20
bcmZo*ZeX4;h0DysGPcGz+CbNA;=D%yKt=}V

delta 20
bcmZo*ZeX4;h0DS+w#GQxz|hEK;=D%yK*t8<

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BW b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BW
index acbe7e11319b8d63e6e287e3143f8d0cc5314c99..641043db9ee91a570b5cf5775ca3180beca3bcc4 100644
GIT binary patch
delta 164
zcmZo+*})>Z<}Cwj6$1m4J_7>-BO@aNZ?uuF`9zV+qVnb%_Eyn`y2hrlF)7t%wKdTu
zX0a20C~`9SIWjT;35Ll=j26oL=9bZhMzPTbh9G4owTuj`K-vOGbC_Ei8We6;zBsRx_{yEjEi~1Th&Hgf+}#QYLR>^aB7q
CGbB*}

delta 110
zcmdnN(!wIL<}Cwj6$1m~Zw4U2$jHDGZKOL<^s=C|xrV(}w4ttXY)neES#6EU#J`G?
zY!+Y+BLgdtHm_x5V7D+dGBzw%<}Cwj6$1lf@kGvW9w{>od#h*zU8C5Tl#N9Ki~y;O2|@q>

delta 40
vcmeyv)WpoW<}Cwj6$1lfrx9C

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CI b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CI
index 15a95d63968f07a18dac5e2e2237abf57dc51541..dadad8e72645ce645f2d4e141d77e798993f2358 100644
GIT binary patch
delta 45
ycmey%)WFQS<}Cwj6$1lf`9#iM2^9@{D}!i5UCY=SlV}4I5N#T5U>-Yh^(6o)yA7`Z

delta 42
vcmZo*{>#L<<}Cwj6$1lf$wbaxQAG`VD}!i5UCY=SlV}4I5N&EOaor^V0`&~K

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CR b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CR
index 942b6466824ccbc6fcba26b7181c9824471c2ed2..08a1ab0eabb2003199dd310bd9cc845f41501ab2 100644
GIT binary patch
delta 51
zcmZ3&ypfr6&07Z6Dh39|6%#q#B_u2~?5(1WEi7YWQfkbj4RnoTHDgk$O(#bGX4IV=
H&gcsOdd?3G

delta 38
ucmdnUyo8x^&07Z6Dh39|*%LY4xw$Q(jV&x=V^XTkCT9F*w3wX2=nDYZ^$Ujp

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FJ b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FJ
index 616f4c6d168a87d0a8b73c691d554226b0b7eec7..443c7c935b0c7ea931722150ad9e6a5b1193c0d1 100644
GIT binary patch
literal 396
zcmb`Dv2Md45QYy+ZfaFZhpJ;F4<78n(gDWUU92n_I`jnyTb`nUsSnd7uaS6D18gAcP)^DS!m53P9O^t?r-2V^NBp3-3^MvHRA
z$3BPD&0RDVhj*gln<_@99E|EvnHjUmtDtR*UUckI!XT(@WZfuSqRVx1B5A@`SK=T4
PnEATV*&_It&eg>a5=lil

literal 147
zcmZ4UmVvdrmw|zSkr70|Fe3w#pCgz6Nl=~5z~tt|z`(SefyuxCXeGpAFat;c0A2?T
AZ2$lO

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FM b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FM
index f58dc40d2a70b06107def71aa481b7ea649fb263..678e85d99e3d978cf8331f108453aa3c9c7fe962 100644
GIT binary patch
literal 297
zcmZ4UmVvd3fq_wh0Z1@1GH^y4TgJwuRGZZ@GOz+^^ID)VgPd`+k+G?HtUz6=aZn;Do4
k41m6c07eEr4WJ*4Yc)ZXNv$RWtBRq5iV;Yb5saV;0fW>qp#T5?

delta 48
ocmZ3H?)<}Cwj6$1lf?nKTaP7^ar0}XpC1A~cEJ^=uSx(N{g

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GY b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GY
index e6666f9979fb7b41cb5d855e02ac85e2abee1284..1636ed429ce4405c48096e262b3a031b90ca9d03 100644
GIT binary patch
literal 397
zcmbVIF>V7P5L_<0SSb?a2`*fi0tprljx?4lcUIbnyY7m-A>q0_Ctu4SGJCcoOX-YY
zcVT8{fbSn_KZw*9At*(Ug-wVlkHhpCXGJY?ngP-KcK5;v5Ip?h^9VA19?
z_AC~Cu6^YH3jKxkkge?@;;#+l3@R{aj{7CZQ*W-RIlK`yuXJav!;hYZqNnX*tR;n6
PQ@e5N4GXH4c_#h>@3u+3

literal 154
zcmZ4UmVvc=3IhWJBO{1_VMYcfKSwYDlAt=9fyq6Rfq^N2f!V;o5NIo-0gM1T015!Z
CaSg)&

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK
index 260696ba9df79a9673c83a961f3f9e271873dbc4..89a9cff102845769307758f6309919c01214fa9d 100644
GIT binary patch
delta 39
vcmcc4{E(S*&07Z6Dh39|8xuKib2Bn>eW*YWZKx7(iplf6nTVocJq8XD?ZCYCc6f_57
zgJ>gNGYiYunrK5^v)GuFiCN0*Kp_hdv&UFJ25y2;w4u2LP?@m_NUp{-8ps10RRb}^
Pz&y6bJSJu1OAAH-zKbS5

delta 128
zcmZ3%vXF&y&07Z6Dh387iHV#Vmf05OW*YWZKx7(iplf6nTVocJQez%%s0(CTMjPo`
z#A?Q*RGZe;0F{^nu>nxb%)&BuVv6#_ej}}LxPBwUnrLGai&&s`(`a*x*cx+lpw1eI
M9s~2(jUOx+0lfbs>Hq)$

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KH b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KH
index f34f0eb1e7f09313e8c6929ca0ebfe50ab3d05a7..3b43e3946f932370509dafdbba02b26018173f67 100644
GIT binary patch
delta 45
zcmey#+|0tc<}Cwj6$1m~uZf&FjOG)|`N_<=<}Cwj6$1m~hl!jyjJgxc8O-2T00~JF?1{eSU3t}8}

delta 90
zcmaFI{DPTt&07Z6Dh39|`x7~HM5Q(Ct&C$*YRrLjw1HtPkZEQ%u~%o}Erp3Y6es>V
bttJ|6VHpdOf~x_l&}3v_Hc&BSWPkwxBpn#n

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LY b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LY
index 0873564e789aba2ef7caf8b388cbd5ece5b90bfe..a3c600057c401a41895c137b258f8f9d80326178 100644
GIT binary patch
delta 26
icmdnaw3Uf-&07Z6Dh38dor#=@tlXB-hPo3Aj{yK=Uk8K$

delta 28
kcmdnWw4I4_&07Z6Dh38dy@{NO?7WuIhDOGw6Z4M&0CETi^#A|>

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MV b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MV
index cef8e087fca652759783482f5661ed694c0d1cbf..7e2e0b3a7621d1016621b1cb5cce599cbdf394e4 100644
GIT binary patch
delta 29
lcmcb_e36-R&07Z6Dh39|6B9XG*~K*Mt<0m1H%_x*1OSVk2)Y0O

delta 30
mcmcb}e2JNJ&07Z6Dh39|lM^{xIm9*Wt<0m1%{ET8VFUn_2MF>2

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NF b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NF
index ab792748002839a237accbf162e657d8b582b72a..59991ff41b641fdcb23c01da6396f02b4f969fb3 100644
GIT binary patch
literal 318
zcmb`CF%H5o3`M^ql?owo280+Ii6M^L(6S&FMlMj;I0Ynk;Q(BXJK(eoz)Yn0M|#gr
z@_3@S0@OeY5vD!M`Et<8

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NI b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NI
index 437f7d196e9914841f40dcf1941b3e3f68288c43..95e956a8413089037b368ff2079726adee96e16f 100644
GIT binary patch
literal 272
zcmZ4UmVvd3fq{{o0Z1@1GH^v38d=1~q*R;NGBU6NX^UE*I0KsziV!0MhmoO?v5Bdf
zIY`n1UD5&}$!Ta|U;vaiftv@^3=#t=0cvLQa|9D0Td2YYn&Juc%TER-0|TI^Ab^p9
YPXp`-O(?~{s$!_1Vg!<91S6#DMjINL#MYRb*H{{8PW-(T0P>FviU0rr

delta 23
fcmdnQynvZ=&07Z6Dh39|=@U6WGBQo(Wn2mXRy_vh

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PK b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PK
index 1c37c1c4138f0c6da01d4c338090d4565b4411bb..6b0027d5661870eb18a3de3f9f11f3b08c6307c2 100644
GIT binary patch
delta 14
VcmdnXyO(#vJVr+I&GQ-MSOF-01d;#%

delta 14
VcmdnXyO(#vJVr*d&GQ-MSOF+_1d#v$

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SZ b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SZ
index bca54b0c328c233d7e586847a28c411a2e602c51..b487a132fdf0afb4ca4f0ce7ce10c417f9d9e815 100644
GIT binary patch
delta 100
zcmaFQypUOQ&07Z6Dh39|84N&zk&%Hb+Q7&>HYTOoyq1xH6-Zmu0>v51jV9`QOzbmI
og9tG)a2OdGnj0D!n*b%b&7;k9EkK&gpqeJWUB$>a`2eFn0I?Am;{X5v

delta 178
zcmZ3;{GM5V&07Z6Dh39|XAD4sk&%Hn+Q3NHJT@k!+Dym1mXU!S$THWls0B(g^c&ev
z)btQDG^;U+HZ+Q@F^)DhkFAL|F*Ub{HJVsps1H*N)MjL8ZfIm|0@Nj_VQ*ztV;*g$
zYZ0pnG8b;@#N(?pnHcyqfP%)gnjp%gR+E8M#ZW=T2;>|F)@UPLvsgwDlVNfZqdov9
CN+~=5

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TJ b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TJ
index 079698424ccb63ddf76c7d1a6066ac7cdf993dfb..a49e8a882fa56b8d39ef68068efbccde3114970f 100644
GIT binary patch
delta 191
zcmX@j@`A;6&07Z6Dh39ocm@UrMn*;k?r39OQ_I+xlxmAwMh12uZLDKi3zTAT(6F~M
z24X{yir5;XXd@FKWgKm26g$z;UP1yWWolqrV;OCrYiz0uGC~um+iYUrSphZ;3rz(T
zLq?z-;u_H=rjyedl@ugQqD?GfYk)dHhFaD{8yJE0X)-c^)lXi+=)wwNydz`V

delta 162
zcmaFCa+<|)&07Z6Dh387Ck6%vMn*;ku4rQu%h;HdYKvM%26iBAtYcXVlwq*du(vV>
zV#8=-UDMbaqi7=&AZ2Vg(bb-h&obIT*Vt4StkHbpoU=U47Al5}KqJL8qD>}OGAc=n
qnM9jd#MW4XOt7qpHZTG!*JNa1wwSz|(S->}u`mVm!Sn&O0s#O5up-z1

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TV b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TV
index 792d2973f42e3c3be6fed17a6bb1aeaa4eea896b..973582a0192176cc2536cfdb8b670e796c4d530a 100644
GIT binary patch
literal 221
zcmZ4UmVveWIs*d(BO@aNceIgZY)neEiH>P4BLh2-WvXLV3zTBuF^V=Y(gjNz1Ep9&
zQXtyMz|hDTD9>(b0MZAQG6T|VmLMq;pd6E*BbWf0Lv=O-Q%D#C1JecuCIbVYFHivh
DJ`^9)

delta 43
icmcc1IGIsw&07Z6@?Hi821Z5@0mTy&3VA?m7ytmY-vyok

diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US
index 2ee936c9039889d4c143c5849207a69b30a5ef69..e0f78752e4d80bc33b5d8464e7d3dc5469eda0a7 100644
GIT binary patch
delta 61
zcmX@ebChR-A*1o+Hm0|XmYd}n`4|~3C+jjrz=S5tGfw8HVqjo0uQ83D%*RpzmJZ*1
ImnDS}034eT_y7O^

delta 50
zcmX@gbC73(A*12s4yL!86&U##C+jmsK)90?7^ksTF)%P0PZngU0E&lie#nx-2mp`f
B4-EhS

diff --git a/java/test/com/google/i18n/phonenumbers/AsYouTypeFormatterTest.java b/java/test/com/google/i18n/phonenumbers/AsYouTypeFormatterTest.java
index 6a48dcca7..da8e8cc4b 100644
--- a/java/test/com/google/i18n/phonenumbers/AsYouTypeFormatterTest.java
+++ b/java/test/com/google/i18n/phonenumbers/AsYouTypeFormatterTest.java
@@ -343,7 +343,7 @@ public class AsYouTypeFormatterTest extends TestCase {
   }
 
   public void testAYTFGBTollFree() {
-     AsYouTypeFormatter formatter = phoneUtil.getAsYouTypeFormatter("gb");
+    AsYouTypeFormatter formatter = phoneUtil.getAsYouTypeFormatter("gb");
     assertEquals("0", formatter.inputDigit('0'));
     assertEquals("08", formatter.inputDigit('8'));
     assertEquals("080", formatter.inputDigit('0'));
diff --git a/java/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java b/java/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java
index 8153694d3..37d70fe71 100644
--- a/java/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java
+++ b/java/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java
@@ -198,6 +198,30 @@ public class PhoneNumberMatcherTest extends TestCase {
     }
   }
 
+  public void testMatchWithSurroundingZipcodes() throws Exception {
+    String number = "415-666-7777";
+    String zipPreceding = "My address is CA 34215. " + number + " is my number.";
+    PhoneNumber expectedResult = phoneUtil.parse(number, "US");
+
+    Iterator iterator = phoneUtil.findNumbers(zipPreceding, "US").iterator();
+    PhoneNumberMatch match = iterator.hasNext() ? iterator.next() : null;
+    assertNotNull("Did not find a number in '" + zipPreceding + "'; expected " + number, match);
+    assertEquals(expectedResult, match.number());
+    assertEquals(number, match.rawString());
+
+    // Now repeat, but this time the phone number has spaces in it. It should still be found.
+    number = "(415) 666 7777";
+
+    String zipFollowing = "My number is " + number + ". 34215 is my zip-code.";
+    iterator = phoneUtil.findNumbers(zipFollowing, "US").iterator();
+
+    PhoneNumberMatch matchWithSpaces = iterator.hasNext() ? iterator.next() : null;
+    assertNotNull("Did not find a number in '" + zipFollowing + "'; expected " + number,
+                  matchWithSpaces);
+    assertEquals(expectedResult, matchWithSpaces.number());
+    assertEquals(number, matchWithSpaces.rawString());
+  }
+
   public void testNoMatchIfRegionIsNull() throws Exception {
     // Fail on non-international prefix if region code is null.
     assertTrue(hasNoMatches(phoneUtil.findNumbers(
@@ -417,7 +441,7 @@ public class PhoneNumberMatcherTest extends TestCase {
   }
 
   /**
-   * Tests numbers found by {@link PhoneNumberUtil#find(CharSequence, String)} in various
+   * Tests numbers found by {@link PhoneNumberUtil#findNumbers(CharSequence, String)} in various
    * textual contexts.
    *
    * @param number the number to test and the corresponding region code to use
diff --git a/java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java
index 82aeb218e..e485b1e8e 100644
--- a/java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java
+++ b/java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java
@@ -372,6 +372,7 @@ public class PhoneNumberUtilTest extends TestCase {
     assertEquals("1234", phoneUtil.format(DE_SHORT_NUMBER, PhoneNumberFormat.NATIONAL));
     assertEquals("+49 1234", phoneUtil.format(DE_SHORT_NUMBER, PhoneNumberFormat.INTERNATIONAL));
 
+    deNumber.clear();
     deNumber.setCountryCode(49).setNationalNumber(41341234);
     assertEquals("04134 1234", phoneUtil.format(deNumber, PhoneNumberFormat.NATIONAL));
   }
@@ -719,12 +720,11 @@ public class PhoneNumberUtilTest extends TestCase {
     assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(BS_MOBILE));
     assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(GB_MOBILE));
     assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(IT_MOBILE));
+    assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(AR_MOBILE));
 
     PhoneNumber mobileNumber = new PhoneNumber();
     mobileNumber.setCountryCode(49).setNationalNumber(15123456789L);
     assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(mobileNumber));
-
-    assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(AR_MOBILE));
   }
 
   public void testIsFixedLine() {
@@ -913,8 +913,8 @@ public class PhoneNumberUtilTest extends TestCase {
     assertEquals(PhoneNumberUtil.ValidationResult.TOO_SHORT,
                  phoneUtil.isPossibleNumberWithReason(number));
 
-    number.setCountryCode(65);
-    number.setNationalNumber(1234567890L);
+    number.clear();
+    number.setCountryCode(65).setNationalNumber(1234567890L);
     assertEquals(PhoneNumberUtil.ValidationResult.IS_POSSIBLE,
                  phoneUtil.isPossibleNumberWithReason(number));
 
diff --git a/java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_JP b/java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_JP
index 82581ad6d574f1daaaf27eb3c16a48da1a97afd3..f1c9af56799b850f328b172bf52cd6a0b0b7acad 100644
GIT binary patch
delta 41
xcmdnOe3hAV&07Z6Dh39|GZQ&`7+E(?lVId!*N91}HmTKQVAfJGoIHzB3IG5o3nc&m

delta 27
jcmcc0yoH%_&07Z6Dh39|)e|{;7+E$>lVF^Do{
           
             [17]|
-            9[1-469]
+            9[1-9]
           
           $1 $2
         
+        
+          6
+          $1 $2
+        
         
           [23]
           $1 $2
@@ -532,7 +537,7 @@
         
       
       
-        [1-37-9]\d{7}
+        [1-36-9]\d{7}
         \d{5,8}
       
       
@@ -556,7 +561,7 @@
         
           (?:
             77|
-            9[1-469]
+            9[1-46-9]
           )\d{6}
         
         \d{8}
@@ -577,6 +582,12 @@
         \d{8}
         80112345
       
+      
+        
+        6027\d{4}
+        \d{8}
+        60271234
+      
       
         
           8[1-7]\d{2}|
@@ -1359,9 +1370,14 @@
           [4-8]
           $1 $2 $3 $4
         
+        
+          9
+          $1 $2 $3 $4
+        
       
       
-        [1-8]\d{7,8}
+        [1-9]\d{7,8}
         \d{5,9}
       
       
@@ -1410,10 +1426,18 @@
         401234567
       
       
+        
         88\d{7}
         \d{9}
         881234567
       
+      
+        
+        900200\d{3}
+        \d{9}
+        900200123
+      
     
 
     
@@ -1849,12 +1873,13 @@
       
       
         
+             since diallable numbers have been found outside the range that the document specifies.
+             Including 716 as well since many numbers seem to have this prefix. -->
         
           7(?:
             [024-6]\d|
-            1[0-489]|
-            3[0124]|
+            1[0-4689]|
+            3[0-6]|
             7[01]|
             8[013-9]|
             9[0-4]
@@ -2549,10 +2574,14 @@
     
 
     
-    
+    
     
       
-        
+        
+          [2-6]
+          $1 $2
+        
+        
           7
           $1 $2 $3
         
@@ -2562,7 +2591,7 @@
         
       
       
-        [2-9]\d{6,7}
+        [2-79]\d{6,7}
         \d{7,8}
       
       
@@ -2605,23 +2634,26 @@
       
         
           7(?:
-            [1-3]\d{6}|
-            4[0-7]\d{5}
+            [1-35]\d{6}|
+            [46][0-7]\d{5}
           )
         
         \d{8}
         71123456
       
-      
-        8\d{6}
-        \d{7}
-        8123456
-      
+      
       
         90\d{5}
         \d{7}
         9012345
       
+      
+        79[12][01]\d{4}
+        \d{8}
+        79101234
+      
     
 
     
@@ -2745,11 +2777,12 @@
         2221234
       
       
+        
         
           6(?:
-            [01]\d|
-            2[0-5]|
-            [67][01])\d{4}
+            [0-2]\d|
+            [67][01]
+          )\d{4}
         
         \d{7}
         6221234
@@ -3087,13 +3120,13 @@
         21234567
       
       
-        
+        
         
           (?:
             0[1-9]|
             4[04-9]|
-            50|
+            5[07]|
             6[067]
           )\d{6}
         
@@ -3854,7 +3887,7 @@
         
           
             [24]|
-            8[389]
+            8[3-9]
           
           $1 $2
         
@@ -3873,7 +3906,14 @@
         22123456
       
       
-        8[389]\d{6}
+        
+        
+          8(?:
+            [389]\d|
+            7[0-3]
+          )\d{5}
+          
         \d{8}
         83123456
       
@@ -5233,7 +5273,79 @@
     
 
     
-    
+    
+    
+    
+      
+        
+          [36-9]
+          $1 $2
+        
+        
+          0
+          $1 $2 $3
+        
+      
+      
+        
+          [36-9]\d{6}|
+          0\d{10}
+        
+        \d{7}(?:\d{4})?
+      
+      
+        
+        
+          (?:
+            3[0-5]|
+            6[25-7]|
+            8[58]
+          )\d{5}
+        
+        \d{7}
+        3212345
+      
+      
+        
+          (?:
+            7[0-4]|
+            9[29]
+          )\d{5}
+        
+        \d{7}
+        7012345
+      
+      
+        
+        0800\d{7}
+        \d{11}
+        08001234567
+      
+      
+        
+        
+          0(?:
+           04|
+           1[34]|
+           8[1-4]
+          )|
+          1(?:
+            0[1-3]|
+            [25]9
+          )|
+          2[289]|
+          30|
+          [45]4|
+          75|
+          91[137]
+        
+        \d{2,3}
+        22
+      
     
 
     
@@ -5263,7 +5375,33 @@
     
 
     
+    
     
+      
+        
+          $1 $2
+        
+      
+      
+        [39]\d{6}
+        \d{7}
+      
+      
+        
+            3[2357]0[1-9]\d{3}|
+            9[2-6]\d{5}
+        
+        3201234
+      
+      
+        
+        
+          3[2357]0[1-9]\d{3}|
+          9[2-7]\d{5}
+        
+        3501234
+      
     
 
     
@@ -5942,7 +6080,7 @@
             9(?:
               [04-9]\d|
               1[02-9]|
-              2[0135-9]|
+              2[0-35-9]|
               3[0-689]
             )
           )\d{6}
@@ -6665,9 +6803,14 @@
         590201234
       
       
+        
         
           690(?:
             00|
+            1[1-9]|
+            2[013-5]|
             [3-5]\d|
             6[0-57-9]|
             7[1-6]|
@@ -7081,8 +7224,78 @@
     
 
     
-    
+    
+    
+      
+        
+          $1 $2
+        
+      
+      
+        [2-4679]\d{6}
+        \d{7}
+      
+      
+        
+          (?:
+            2(?:
+              1[6-9]|
+              2[0-35-9]|
+              3[1-4]|
+              5[3-9]|
+              6\d|
+              7[0-24-79]
+            )|
+            3(?:
+              2[25-9]|
+              3\d
+            )|
+            4(?:
+              4[0-24]|
+              5[56]
+            )|
+            77[1-57]
+          )\d{4}
+        
+        2201234
+      
+      
+        
+        6\d{6}
+        6091234
+      
+      
+        
+          (?:
+            289|
+            862
+          )\d{4}
+        
+        2891234
+      
+      
+        9008\d{3}
+        9008123
+      
+      
+        
+          0(?:
+            02|
+            171|
+            444|
+            7[67]7|
+            801|
+            9(?:
+              0[78]|
+              [2-47]
+            )
+          )
+       
+       \d{3,4}
+       0801
+      
     
 
     
@@ -7141,6 +7354,7 @@
       
         8[1-3]\d{6}
         \d{8}
+        81123456
       
     
 
@@ -9116,19 +9330,19 @@
           876(?:
             (?:
               5[0-26]|
-              6\d|
-              7[1-6]|
-              9[2-8]
+              6\d
             )\d{5}|
             (?:
               7(?:
                 0[2-689]|
+                [1-6]\d|
                 8[056]|
                 9[45]
               )|
               9(?:
                 0[1-8]|
                 1[02378]|
+                [2-8]\d|
                 9[2-468]
               )
             )\d{4}
@@ -9137,18 +9351,18 @@
         8765123456
       
       
-        
+        
         
           876(?:
             (?:
-              21|
+              2[178]|
               [348]\d|
-              5[78]|
-              77
+              5[78]
             )\d|
             7(?:
               0[07]|
+              7\d|
               8[1-47-9]|
               9[0-36-9]
             )|
@@ -10341,15 +10555,18 @@
         23456789
       
       
-        
+        
         
           (?:
             (?:
               1[0-35-9]|
               9[1-49]
             )[1-9]|
-            85[2-689]
+            8(?:
+              0[89]|
+              5[2-689]
+            )
           )\d{5}
         
         \d{8}
@@ -11145,7 +11362,7 @@
             [89][01]|
             7(?:
               [01]|
-              66)
+              6[67])
           
           $1 $2 $3
         
@@ -11173,7 +11390,7 @@
             3\d|
             7(?:
               [01]\d|
-              66
+              6[67]
             )
           )\d{5}
         
@@ -11181,14 +11398,14 @@
         71123456
       
       
-        8[01]\d{6}
+        9[01]\d{6}
         \d{8}
-        80123456
+        90123456
       
       
-        9[01]\d{6}
+        8[01]\d{6}
         \d{8}
-        90123456
+        80123456
       
     
 
@@ -11838,7 +12055,9 @@
         212345678
       
       
-        9[12356]\d{7}
+        
+        9[1-6]\d{7}
         \d{9}
         912345678
       
@@ -13011,9 +13230,10 @@
         6701234
       
       
+        
         
           (?:
-            7[36-9]|
+            7[3-9]|
             9[6-9]
           )\d{5}
         
@@ -13712,7 +13932,43 @@
     
 
     
+    
+    
     
+      
+        
+           1
+          $1 $2
+        
+        
+          3
+          $1 $2
+        
+      
+      
+        [13]\d{5}
+        \d{5,6}
+      
+      
+        
+        
+          (?:
+            1(?:
+              06|
+              17|
+              28|
+              39
+            )|
+            3[012]\d
+          )\d{3}
+        
+        106609
+      
+      
+        38\d{4}
+        381234
+      
     
 
     
@@ -13818,8 +14074,29 @@
     
 
     
-    
+    
+    
+      
+        
+          $1 $2
+        
+      
+      
+        [128]\d{7}
+        \d{8}
+      
+      
+        2\d{7}
+        21234567
+      
+      
+        8\d{7}
+        81234567
+      
+      
+        1800\d{4}
+        18001234
+      
     
 
     
@@ -14047,8 +14324,41 @@
     
 
     
-    
+    
+    
+      
+        
+          $1 $2
+        
+      
+      
+        [458]\d{6}
+        \d{7}
+      
+      
+        
+          (?:
+            444|
+            888
+          )\d{4}
+        
+        4441234
+      
+      
+        55[5-9]\d{4}
+        5551234
+      
+      
+        
+          1(?:
+            1[012]|
+            23|
+            92
+          )
+        
+        \d{3}
+        110
+      
     
 
     
@@ -14239,7 +14549,7 @@
     
     
     
-    
       
@@ -14727,13 +15037,15 @@
         2123456789
       
       
+        
         
           3(?:
             0\d|
             1[2-5]|
             2[1-3]|
             3[1-6]|
-            4[2-6]|
+            4[2-7]|
             64
           )\d{7}
         
@@ -16620,22 +16932,16 @@
 
     
     
-    
     
       
-        
-          [2-6]
-          $1 $2
-        
         
           [027]
           $1 $2
         
       
       
-        [02-7]\d{6,7}
-        \d{7,8}
+        [027]\d{7}
+        \d{8}
       
       
         0800\d{4}
@@ -16643,10 +16949,8 @@
         08001234
       
       
-        
         
-          2?(?:
+          2(?:
             2(?:
               0[07]|
               [13]7|
@@ -16660,10 +16964,6 @@
             )|
             (?:
               40[4-69]|
-              16|
-              2[12]|
-              3[57]|
-              [4578]2|
               67
             )|
             5(?:
@@ -16675,20 +16975,14 @@
             )
           )\d{4}
         
-        2171234
+        22171234
       
       
-        
-          (?:
-            6|
-            7[6-8]
-          )\d{6}
-        
+        7[6-8]\d{6}
         76123456
       
       
         0800\d{4}
-        \d{8}
         08001234
       
     
@@ -16931,7 +17225,7 @@
     
     
     
+               nationalPrefix="8" nationalPrefixFormattingRule="($NP) $FG">
       
         
           
@@ -16940,9 +17234,10 @@
           
           $1 $2 $3
         
-        
+        
           
             4[48]|
+            5|
             9(?:
               19|
               [0235-9]
@@ -16972,7 +17267,7 @@
         
       
       
-        [349]\d{8}
+        [3-59]\d{8}
         \d{3,9}
       
       
@@ -16981,7 +17276,7 @@
             3(?:
               1[3-5]|
               2[245]|
-              31|
+              3[12]|
               4[24-7]|
               5[25]|
               72
@@ -16998,7 +17293,12 @@
       
         
-        9[0-35-9]\d{7}
+        
+          (?:
+            505|
+            9[0-35-9]\d
+          )\d{6}
+        
         \d{9}
         917123456
       
@@ -17307,7 +17607,26 @@
     
 
     
+    
     
+      
+      
+        [29]\d{4,5}
+        \d{5,6}
+      
+      
+        2[02-9]\d{3}
+        \d{5}
+        20123
+      
+      
+        
+        90\d{4}
+        \d{6}
+        901234
+      
     
 
     
@@ -17741,7 +18060,7 @@
               0[1-57-9]|
               1[0235-8]|
               20|
-              3[014]|
+              3[0149]|
               4[01]|
               5[19]|
               6[1-37]|
@@ -17783,7 +18102,7 @@
             9(?:
               0[1346-9]|
               1[02-9]|
-              2[058]|
+              2[0589]|
               3[1678]|
               4[0179]|
               5[1246]|
@@ -17833,7 +18152,7 @@
               0[1-57-9]|
               1[0235-8]|
               20|
-              3[014]|
+              3[0149]|
               4[01]|
               5[19]|
               6[1-37]|
@@ -17875,7 +18194,7 @@
             9(?:
               0[1346-9]|
               1[02-9]|
-              2[058]|
+              2[0589]|
               3[1678]|
               4[0179]|
               5[1246]|
diff --git a/resources/PhoneNumberMetaDataForTesting.xml b/resources/PhoneNumberMetaDataForTesting.xml
index 0293daeac..661bdd2b4 100644
--- a/resources/PhoneNumberMetaDataForTesting.xml
+++ b/resources/PhoneNumberMetaDataForTesting.xml
@@ -365,6 +365,12 @@
           [23]
           $1 $2 $3
         
+        
+        
+          [23]
+          *$1
+