diff --git a/java/release_notes.txt b/java/release_notes.txt index 3460a14f1..5784e0ed8 100644 --- a/java/release_notes.txt +++ b/java/release_notes.txt @@ -1,3 +1,14 @@ +Apr 11th, 2011 +* Bug fixes: + - Adding date exclusion pattern in PhoneNumberMatcher. + - Fixing bug with selecting a suitable region for numbers with leading zeros where mutiple regions + for that country code are possible. +* Metadata changes: + - Updates: AG, AI, AS, BB, BM, BS, CA, DM, DO, ET, FO, GD, GE, GU, IN, JM, KN, KY, LC, MN, MP, MR, + MS, NO, PR, TC, TR, TT, US, VC, VG, VI + - New countries: CK, FK, GT, IO, KI, SJ, SV +* Documentation updates and some small refactoring to AsYouTypeFormatter + Mar 31st, 2011 * New functionality: - Can parse and format numbers in RFC-3966 format. diff --git a/java/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java b/java/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java index 15d9313d2..1dac89a1a 100644 --- a/java/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java +++ b/java/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java @@ -28,13 +28,13 @@ import java.util.regex.Pattern; /** * A formatter which formats phone numbers as they are entered. * - * An AsYouTypeFormatter could be created by invoking the getAsYouTypeFormatter method of the - * PhoneNumberUtil. After that digits could be added by invoking the inputDigit method on the - * formatter instance, and the partially formatted phone number will be returned each time a digit - * is added. The clear method could be invoked before a new number needs to be formatted. + *

An AsYouTypeFormatter could be created by invoking + * {@link PhoneNumberUtil#getAsYouTypeFormatter}. After that digits could 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. * - * See testAsYouTypeFormatterUS(), testAsYouTestFormatterGB() and testAsYouTypeFormatterDE() in - * PhoneNumberUtilTest.java for more details on how the formatter is to be used. + *

See the unittests for more details on how the formatter is to be used. * * @author Shaopeng Jia */ @@ -47,9 +47,12 @@ public class AsYouTypeFormatter { private StringBuffer accruedInputWithoutFormatting = new StringBuffer(); private boolean ableToFormat = true; private boolean isInternationalFormatting = false; - private boolean isExpectingCountryCode = false; + private boolean isExpectingCountryCallingCode = false; private final PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); private String defaultCountry; + + private static final PhoneMetadata EMPTY_METADATA = + new PhoneMetadata().setInternationalPrefix("NA"); private PhoneMetadata defaultMetaData; private PhoneMetadata currentMetaData; @@ -79,8 +82,6 @@ public class AsYouTypeFormatter { // The position of a digit upon which inputDigitAndRememberPosition is most recently invoked, as // found in accruedInputWithoutFormatting. private int positionToRemember = 0; - private Pattern nationalPrefixForParsing; - private Pattern internationalPrefix; private StringBuffer prefixBeforeNationalNumber = new StringBuffer(); private StringBuffer nationalNumber = new StringBuffer(); private List possibleFormats = new ArrayList(); @@ -96,21 +97,18 @@ public class AsYouTypeFormatter { */ AsYouTypeFormatter(String regionCode) { defaultCountry = regionCode; - initializeCountrySpecificInfo(defaultCountry); + currentMetaData = getMetadataForRegion(defaultCountry); defaultMetaData = currentMetaData; } - private void initializeCountrySpecificInfo(String regionCode) { - currentMetaData = phoneUtil.getMetadataForRegion(regionCode); - if (currentMetaData == null) { - // Set to a default instance of the metadata. This allows us to function with an incorrect - // region code, even if formatting only works for numbers specified with "+". - currentMetaData = new PhoneMetadata().setInternationalPrefix("NA"); + private PhoneMetadata getMetadataForRegion(String regionCode) { + PhoneMetadata metadata = phoneUtil.getMetadataForRegion(regionCode); + if (metadata != null) { + return metadata; } - nationalPrefixForParsing = - regexCache.getPatternForRegex(currentMetaData.getNationalPrefixForParsing()); - internationalPrefix = - regexCache.getPatternForRegex("\\+|" + currentMetaData.getInternationalPrefix()); + // Set to a default instance of the metadata. This allows us to function with an incorrect + // region code, even if formatting only works for numbers specified with "+". + return EMPTY_METADATA; } // Returns true if a new template is created as opposed to reusing the existing template. @@ -141,8 +139,7 @@ public class AsYouTypeFormatter { } private void narrowDownPossibleFormats(String leadingDigits) { - int lengthOfLeadingDigits = leadingDigits.length(); - int indexOfLeadingDigitsPattern = lengthOfLeadingDigits - MIN_LEADING_DIGITS_LENGTH; + int indexOfLeadingDigitsPattern = leadingDigits.length() - MIN_LEADING_DIGITS_LENGTH; Iterator it = possibleFormats.iterator(); while (it.hasNext()) { NumberFormat format = it.next(); @@ -160,7 +157,6 @@ public class AsYouTypeFormatter { } private boolean createFormattingTemplate(NumberFormat format) { - String numberFormat = format.getFormat(); String numberPattern = format.getPattern(); // The formatter doesn't format numbers when numberPattern contains "|", e.g. @@ -175,7 +171,7 @@ public class AsYouTypeFormatter { // Replace any standalone digit (not the one in d{}) with \d numberPattern = STANDALONE_DIGIT_PATTERN.matcher(numberPattern).replaceAll("\\\\d"); formattingTemplate.setLength(0); - String tempTemplate = getFormattingTemplate(numberPattern, numberFormat); + String tempTemplate = getFormattingTemplate(numberPattern, format.getFormat()); if (tempTemplate.length() > nationalNumber.length()) { formattingTemplate.append(tempTemplate); return true; @@ -215,10 +211,10 @@ public class AsYouTypeFormatter { positionToRemember = 0; originalPosition = 0; isInternationalFormatting = false; - isExpectingCountryCode = false; + isExpectingCountryCallingCode = false; possibleFormats.clear(); if (!currentMetaData.equals(defaultMetaData)) { - initializeCountrySpecificInfo(defaultCountry); + currentMetaData = getMetadataForRegion(defaultCountry); } } @@ -226,8 +222,9 @@ public class AsYouTypeFormatter { * Formats a phone number on-the-fly as each digit is entered. * * @param nextChar the most recently entered digit of a phone number. Formatting characters are - * allowed, but they are removed from the result. Full width digits and Arabic-indic digits - * are allowed, and will be shown as they are. + * allowed, but as soon as they are encountered this method formats the number as entered and + * not "as you type" anymore. Full width digits and Arabic-indic digits are allowed, and will + * be shown as they are. * @return the partially formatted phone number. */ public String inputDigit(char nextChar) { @@ -236,9 +233,10 @@ public class AsYouTypeFormatter { } /** - * Same as inputDigit, but remembers the position where nextChar is inserted, so that it could be - * retrieved later by using getRememberedPosition(). The remembered position will be automatically - * adjusted if additional formatting characters are later inserted/removed in front of nextChar. + * 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 + * position will be automatically adjusted if additional formatting characters are later + * inserted/removed in front of {@code nextChar}. */ public String inputDigitAndRememberPosition(char nextChar) { currentOutput = inputDigitWithOptionToRememberPosition(nextChar, true); @@ -265,29 +263,29 @@ public class AsYouTypeFormatter { // We start to attempt to format only when at least MIN_LEADING_DIGITS_LENGTH digits (the plus // sign is counted as a digit as well for this purpose) have been entered. switch (accruedInputWithoutFormatting.length()) { - case 0: // this is the case where the first few inputs are neither digits nor the plus sign. + case 0: case 1: case 2: return accruedInput.toString(); case 3: if (attemptToExtractIdd()) { - isExpectingCountryCode = true; + isExpectingCountryCallingCode = true; } else { // No IDD or plus sign is found, must be entering in national format. removeNationalPrefixFromNationalNumber(); return attemptToChooseFormattingPattern(); } case 4: case 5: - if (isExpectingCountryCode) { - if (attemptToExtractCountryCode()) { - isExpectingCountryCode = false; + if (isExpectingCountryCallingCode) { + if (attemptToExtractCountryCallingCode()) { + isExpectingCountryCallingCode = false; } return prefixBeforeNationalNumber + nationalNumber.toString(); } - // We make a last attempt to extract a country code at the 6th digit because the maximum - // length of IDD and country code are both 3. + // We make a last attempt to extract a country calling code at the 6th digit because the + // maximum length of IDD and country calling code are both 3. case 6: - if (isExpectingCountryCode && !attemptToExtractCountryCode()) { + if (isExpectingCountryCallingCode && !attemptToExtractCountryCallingCode()) { ableToFormat = false; return accruedInput.toString(); } @@ -326,22 +324,19 @@ public class AsYouTypeFormatter { /** * Returns the current position in the partially formatted phone number of the character which was - * previously passed in as the parameter of inputDigitAndRememberPosition(). + * previously passed in as the parameter of {@link #inputDigitAndRememberPosition}. */ public int getRememberedPosition() { if (!ableToFormat) { return originalPosition; } int accruedInputIndex = 0, currentOutputIndex = 0; - int currentOutputLength = currentOutput.length(); - while (accruedInputIndex < positionToRemember && currentOutputIndex < currentOutputLength) { + while (accruedInputIndex < positionToRemember && currentOutputIndex < currentOutput.length()) { if (accruedInputWithoutFormatting.charAt(accruedInputIndex) == currentOutput.charAt(currentOutputIndex)) { accruedInputIndex++; - currentOutputIndex++; - } else { - currentOutputIndex++; } + currentOutputIndex++; } return currentOutputIndex; } @@ -384,6 +379,8 @@ public class AsYouTypeFormatter { prefixBeforeNationalNumber.append("1 "); isInternationalFormatting = true; } else if (currentMetaData.hasNationalPrefix()) { + Pattern nationalPrefixForParsing = + regexCache.getPatternForRegex(currentMetaData.getNationalPrefixForParsing()); Matcher m = nationalPrefixForParsing.matcher(nationalNumber); if (m.lookingAt()) { // When the national prefix is detected, we use international formatting rules instead of @@ -405,14 +402,17 @@ public class AsYouTypeFormatter { * defaultCountry. */ private boolean attemptToExtractIdd() { + Pattern internationalPrefix = + regexCache.getPatternForRegex("\\" + PhoneNumberUtil.PLUS_SIGN + "|" + + currentMetaData.getInternationalPrefix()); Matcher iddMatcher = internationalPrefix.matcher(accruedInputWithoutFormatting); if (iddMatcher.lookingAt()) { isInternationalFormatting = true; - int startOfCountryCode = iddMatcher.end(); + int startOfCountryCallingCode = iddMatcher.end(); nationalNumber.setLength(0); - nationalNumber.append(accruedInputWithoutFormatting.substring(startOfCountryCode)); + nationalNumber.append(accruedInputWithoutFormatting.substring(startOfCountryCallingCode)); prefixBeforeNationalNumber.append( - accruedInputWithoutFormatting.substring(0, startOfCountryCode)); + accruedInputWithoutFormatting.substring(0, startOfCountryCallingCode)); if (accruedInputWithoutFormatting.charAt(0) != PhoneNumberUtil.PLUS_SIGN) { prefixBeforeNationalNumber.append(" "); } @@ -422,41 +422,41 @@ public class AsYouTypeFormatter { } /** - * Extracts country code from the beginning of nationalNumber to prefixBeforeNationalNumber when - * they are available, and places the remaining input into nationalNumber. + * Extracts the country calling code from the beginning of nationalNumber to + * prefixBeforeNationalNumber when they are available, and places the remaining input into + * nationalNumber. * - * @return true when a valid country code can be found. + * @return true when a valid country calling code can be found. */ - private boolean attemptToExtractCountryCode() { + private boolean attemptToExtractCountryCallingCode() { if (nationalNumber.length() == 0) { return false; } - StringBuffer numberWithoutCountryCode = new StringBuffer(); - int countryCode = phoneUtil.extractCountryCode(nationalNumber, numberWithoutCountryCode); + StringBuffer numberWithoutCountryCallingCode = new StringBuffer(); + int countryCode = phoneUtil.extractCountryCode(nationalNumber, numberWithoutCountryCallingCode); if (countryCode == 0) { return false; - } else { - nationalNumber.setLength(0); - nationalNumber.append(numberWithoutCountryCode); - String newRegionCode = phoneUtil.getRegionCodeForCountryCode(countryCode); - if (!newRegionCode.equals(defaultCountry)) { - initializeCountrySpecificInfo(newRegionCode); - } - String countryCodeString = Integer.toString(countryCode); - prefixBeforeNationalNumber.append(countryCodeString).append(" "); } + nationalNumber.setLength(0); + nationalNumber.append(numberWithoutCountryCallingCode); + String newRegionCode = phoneUtil.getRegionCodeForCountryCode(countryCode); + if (newRegionCode != defaultCountry) { + currentMetaData = getMetadataForRegion(newRegionCode); + } + String countryCodeString = Integer.toString(countryCode); + prefixBeforeNationalNumber.append(countryCodeString).append(" "); return true; } // Accrues digits and the plus sign to accruedInputWithoutFormatting for later use. If nextChar // contains a digit in non-ASCII format (e.g. the full-width version of digits), it is first // normalized to the ASCII version. The return value is nextChar itself, or its normalized - // version, if nextChar is a digit in non-ASCII format. + // version, if nextChar is a digit in non-ASCII format. This method assumes its input is either a + // digit or the plus sign. private char normalizeAndAccrueDigitsAndPlusSign(char nextChar, boolean rememberPosition) { if (nextChar == PhoneNumberUtil.PLUS_SIGN) { accruedInputWithoutFormatting.append(nextChar); - } - if (PhoneNumberUtil.DIGIT_MAPPINGS.containsKey(nextChar)) { + } else { nextChar = PhoneNumberUtil.DIGIT_MAPPINGS.get(nextChar); accruedInputWithoutFormatting.append(nextChar); nationalNumber.append(nextChar); diff --git a/java/src/com/google/i18n/phonenumbers/CountryCodeToRegionCodeMap.java b/java/src/com/google/i18n/phonenumbers/CountryCodeToRegionCodeMap.java index 8d4b1f9ce..eebb724b8 100644 --- a/java/src/com/google/i18n/phonenumbers/CountryCodeToRegionCodeMap.java +++ b/java/src/com/google/i18n/phonenumbers/CountryCodeToRegionCodeMap.java @@ -132,8 +132,9 @@ public class CountryCodeToRegionCodeMap { listWithRegionCode.add("SE"); countryCodeToRegionCodeMap.put(46, listWithRegionCode); - listWithRegionCode = new ArrayList(1); + listWithRegionCode = new ArrayList(2); listWithRegionCode.add("NO"); + listWithRegionCode.add("SJ"); countryCodeToRegionCodeMap.put(47, listWithRegionCode); listWithRegionCode = new ArrayList(1); diff --git a/java/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java b/java/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java index 1905b5e44..09bc51e57 100644 --- a/java/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java +++ b/java/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java @@ -68,6 +68,13 @@ final class PhoneNumberMatcher implements Iterator { */ private static final Pattern PUB_PAGES = Pattern.compile("\\d{1,5}-+\\d{1,5}\\s{0,4}\\(\\d{1,4}"); + /** + * Matches strings that look like dates using "/" as a separator. Examples: 3/10/2011, 31/10/96 or + * 08/31/95. + */ + private static final Pattern SLASH_SEPARATED_DATES = + Pattern.compile("(?:(?:[0-3]?\\d/[01]?\\d)|(?:[01]?\\d/[0-3]?\\d))/(?:[12]\\d)?\\d{2}"); + static { /* Builds the PATTERN and INNER regular expression patterns. The building blocks below * exist to make the patterns more easily understood. */ @@ -268,8 +275,8 @@ final class PhoneNumberMatcher implements Iterator { * @return the match found, null if none can be found */ private PhoneNumberMatch extractMatch(CharSequence candidate, int offset) { - // Skip a match that is more likely a publication page reference. - if (PUB_PAGES.matcher(candidate).find()) { + // Skip a match that is more likely a publication page reference or a date. + if (PUB_PAGES.matcher(candidate).find() || SLASH_SEPARATED_DATES.matcher(candidate).find()) { return null; } diff --git a/java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index 13a5bc2e1..23c3446f8 100644 --- a/java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -1527,7 +1527,7 @@ public class PhoneNumberUtil { private String getRegionCodeForNumberFromRegionList(PhoneNumber number, List regionCodes) { - String nationalNumber = String.valueOf(number.getNationalNumber()); + String nationalNumber = getNationalSignificantNumber(number); for (String regionCode : regionCodes) { // If leadingDigits is present, use this. Otherwise, do full validation. PhoneMetadata metadata = getMetadataForRegion(regionCode); @@ -1663,6 +1663,24 @@ public class PhoneNumberUtil { return isPossibleNumberWithReason(number) == ValidationResult.IS_POSSIBLE; } + /** + * Helper method to check a number against a particular pattern and determine whether it matches, + * or is too short or too long. Currently, if a number pattern suggests that numbers of length 7 + * and 10 are possible, and a number in between these possible lengths is entered, such as of + * length 8, this will return TOO_LONG. + */ + private ValidationResult testNumberLengthAgainstPattern(Pattern numberPattern, String number) { + Matcher numberMatcher = numberPattern.matcher(number); + if (numberMatcher.matches()) { + return ValidationResult.IS_POSSIBLE; + } + if (numberMatcher.lookingAt()) { + return ValidationResult.TOO_LONG; + } else { + return ValidationResult.TOO_SHORT; + } + } + /** * Check whether a phone number is a possible number. It provides a more lenient check than * {@link #isValidNumber} in the following sense: @@ -1708,14 +1726,9 @@ public class PhoneNumberUtil { return ValidationResult.IS_POSSIBLE; } } - String possibleNumberPattern = generalNumDesc.getPossibleNumberPattern(); - Matcher m = regexCache.getPatternForRegex(possibleNumberPattern).matcher(nationalNumber); - if (m.lookingAt()) { - return (m.end() == nationalNumber.length()) ? ValidationResult.IS_POSSIBLE - : ValidationResult.TOO_LONG; - } else { - return ValidationResult.TOO_SHORT; - } + Pattern possibleNumberPattern = + regexCache.getPatternForRegex(generalNumDesc.getPossibleNumberPattern()); + return testNumberLengthAgainstPattern(possibleNumberPattern, nationalNumber); } /** @@ -1869,37 +1882,34 @@ public class PhoneNumberUtil { throw new NumberParseException(NumberParseException.ErrorType.INVALID_COUNTRY_CODE, "Country calling code supplied was not recognised."); } else if (defaultRegionMetadata != null) { - // Check to see if the number is valid for the default region already. If not, we check to - // see if the country calling code for the default region is present at the start of the - // number. - PhoneNumberDesc generalDesc = defaultRegionMetadata.getGeneralDesc(); - Pattern validNumberPattern = - regexCache.getPatternForRegex(generalDesc.getNationalNumberPattern()); - if (!validNumberPattern.matcher(fullNumber).matches()) { - int defaultCountryCode = defaultRegionMetadata.getCountryCode(); - String defaultCountryCodeString = String.valueOf(defaultCountryCode); - String normalizedNumber = fullNumber.toString(); - if (normalizedNumber.startsWith(defaultCountryCodeString)) { - // If so, strip this, and see if the resultant number is valid. - StringBuffer potentialNationalNumber = - new StringBuffer(normalizedNumber.substring(defaultCountryCodeString.length())); - maybeStripNationalPrefixAndCarrierCode(potentialNationalNumber, defaultRegionMetadata); - Matcher possibleNumberMatcher = - regexCache.getPatternForRegex(generalDesc.getPossibleNumberPattern()).matcher( - potentialNationalNumber); - // If the resultant number is either valid, or still too long even with the country - // calling code stripped, we consider this a better result and keep the potential national - // number. - if (validNumberPattern.matcher(potentialNationalNumber).matches() || - (possibleNumberMatcher.lookingAt() && - possibleNumberMatcher.end() != potentialNationalNumber.length())) { - nationalNumber.append(potentialNationalNumber); - if (keepRawInput) { - phoneNumber.setCountryCodeSource(CountryCodeSource.FROM_NUMBER_WITHOUT_PLUS_SIGN); - } - phoneNumber.setCountryCode(defaultCountryCode); - return defaultCountryCode; + // Check to see if the number starts with the country calling code for the default region. If + // so, we remove the country calling code, and do some checks on the validity of the number + // before and after. + int defaultCountryCode = defaultRegionMetadata.getCountryCode(); + String defaultCountryCodeString = String.valueOf(defaultCountryCode); + String normalizedNumber = fullNumber.toString(); + if (normalizedNumber.startsWith(defaultCountryCodeString)) { + StringBuffer potentialNationalNumber = + new StringBuffer(normalizedNumber.substring(defaultCountryCodeString.length())); + PhoneNumberDesc generalDesc = defaultRegionMetadata.getGeneralDesc(); + Pattern validNumberPattern = + regexCache.getPatternForRegex(generalDesc.getNationalNumberPattern()); + maybeStripNationalPrefixAndCarrierCode(potentialNationalNumber, defaultRegionMetadata); + 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. + if ((!validNumberPattern.matcher(fullNumber).matches() && + validNumberPattern.matcher(potentialNationalNumber).matches()) || + testNumberLengthAgainstPattern(possibleNumberPattern, fullNumber.toString()) + == ValidationResult.TOO_LONG) { + nationalNumber.append(potentialNationalNumber); + if (keepRawInput) { + phoneNumber.setCountryCodeSource(CountryCodeSource.FROM_NUMBER_WITHOUT_PLUS_SIGN); } + phoneNumber.setCountryCode(defaultCountryCode); + return defaultCountryCode; } } } diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AG b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AG index 8679e74bb..ce1d50894 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AG and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AG differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AI b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AI index 8a3623756..2bdd9da80 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AI and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AI differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AS b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AS index 81d04c8b7..76f517cb2 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AS and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AS differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BB b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BB index 74345e75a..553a1de11 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BB and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BB differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BM b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BM index 9bb1b0a99..c50e099a3 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BM and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BM differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BS b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BS index 4ba983cbe..23bbf755b 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BS and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BS differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CA b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CA index d58714a64..5d9bfb2ad 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CA and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CA differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CK b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CK index 4f01ce284..ce2a8ec35 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CK and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CK differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DM b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DM index 486ba1552..47184070d 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DM and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DM differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DO b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DO index 5ee5e4d78..c48d82cb7 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DO and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_DO differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ET b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ET index 443dcb9cd..c6d0e6470 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ET and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_ET differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FK b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FK index 9ef7a8cfa..47e774d24 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FK and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FK differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GD b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GD index b54ca6270..ef111ddd1 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GD and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GD differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GE b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GE index f19410726..b385664ae 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GE and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GE differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GT b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GT index 5d68cc688..2f9f995ad 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GT and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GT differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GU b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GU index 3a455def4..7cd77012f 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GU and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GU differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IN b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IN index f8fafa942..5134699a0 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IN and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IN differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IO b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IO index 3213c5ad6..7731fb8c3 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IO and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IO differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_JM b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_JM index eef5197ee..bff2a7b67 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_JM and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_JM differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KI b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KI index 2cf436562..1b754cc33 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KI and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KI differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KN b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KN index 746a95aa0..c575305a6 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KN and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KN differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KY b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KY index 2e285c1b7..5bfc93e27 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KY and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KY differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LC b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LC index 3b3ab6ba8..3239dd667 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LC and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LC differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MN b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MN index ebbcc6cd5..b96b7f9e3 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MN and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MN differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MP b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MP index 7b51d36ac..ca8b834a9 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MP and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MP differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MR b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MR index dd9fa9e82..d4e34bc55 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MR and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MR differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MS b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MS index b31c305a5..c6d5fe50b 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MS and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MS differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NO b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NO index b258badd9..cf7b46ede 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NO and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NO differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PR b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PR index 7adcde065..ed7165b87 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PR and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PR differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SJ b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SJ new file mode 100644 index 000000000..aca19d3bf Binary files /dev/null and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SJ differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SV b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SV index 0fc9f706a..695ef3f14 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SV and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SV differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TC b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TC index 056739d39..0db939538 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TC and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TC differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TR b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TR index 32b88e1b3..df54d356e 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TR and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TR differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TT b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TT index ddbdfc6af..233023376 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TT and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TT differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US index 03d97c8fc..2ee936c90 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VC b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VC index 9d28676dc..8616e4ef5 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VC and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VC differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VG b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VG index 6d1fbe29a..17db04b69 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VG and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VG differ diff --git a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VI b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VI index fd9447d90..2af1716ee 100644 Binary files a/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VI and b/java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_VI differ diff --git a/java/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java b/java/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java index d0485f8d3..8153694d3 100644 --- a/java/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java +++ b/java/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java @@ -453,7 +453,18 @@ public class PhoneNumberMatcherTest extends TestCase { "As quoted by Alfonso 12-15 (2009), you may call me at ", "")); contextPairs.add(new NumberContext( "As quoted by Alfonso et al. 12-15 (2009), you may call me at ", "")); - // with a postfix stripped off as it looks like the start of another number + // With dates, written in the American style. + contextPairs.add(new NumberContext( + "As I said on 03/10/2011, you may call me at ", "")); + contextPairs.add(new NumberContext( + "As I said on 03/27/2011, you may call me at ", "")); + contextPairs.add(new NumberContext( + "As I said on 31/8/2011, you may call me at ", "")); + contextPairs.add(new NumberContext( + "As I said on 1/12/2011, you may call me at ", "")); + contextPairs.add(new NumberContext( + "I was born on 10/12/82. Please call me at ", "")); + // With a postfix stripped off as it looks like the start of another number contextPairs.add(new NumberContext("Call ", "/x12 more")); doTestInContext(number, defaultCountry, contextPairs, Leniency.POSSIBLE); diff --git a/java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index 432e6c819..82aeb218e 100644 --- a/java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -140,7 +140,7 @@ public class PhoneNumberUtilTest extends TestCase { assertEquals("$1 $2 $3", metadata.getNumberFormat(0).getFormat()); assertEquals("[13-9]\\d{9}|2[0-35-9]\\d{8}", metadata.getGeneralDesc().getNationalNumberPattern()); - assertEquals("\\d{7,10}", metadata.getGeneralDesc().getPossibleNumberPattern()); + assertEquals("\\d{7}(?:\\d{3})?", metadata.getGeneralDesc().getPossibleNumberPattern()); assertTrue(metadata.getGeneralDesc().exactlySameAs(metadata.getFixedLine())); assertEquals("\\d{10}", metadata.getTollFree().getPossibleNumberPattern()); assertEquals("900\\d{7}", metadata.getPremiumRate().getNationalNumberPattern()); @@ -913,6 +913,11 @@ public class PhoneNumberUtilTest extends TestCase { assertEquals(PhoneNumberUtil.ValidationResult.TOO_SHORT, phoneUtil.isPossibleNumberWithReason(number)); + number.setCountryCode(65); + number.setNationalNumber(1234567890L); + assertEquals(PhoneNumberUtil.ValidationResult.IS_POSSIBLE, + phoneUtil.isPossibleNumberWithReason(number)); + // Try with number that we don't have metadata for. PhoneNumber adNumber = new PhoneNumber(); adNumber.setCountryCode(376).setNationalNumber(12345L); @@ -1242,9 +1247,9 @@ public class PhoneNumberUtilTest extends TestCase { } number.clear(); try { - String phoneNumber = "(1 610) 619 43"; + String phoneNumber = "(1 610) 619"; StringBuffer numberToFill = new StringBuffer(); - assertEquals("Should not have extracted a country calling code - invalid number both " + + assertEquals("Should not have extracted a country calling code - too short number both " + "before and after extraction of uncertain country calling code.", 0, phoneUtil.maybeExtractCountryCode(phoneNumber, metadata, numberToFill, true, diff --git a/java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_SG b/java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_SG index 1dbb03bcd..0838f554c 100644 Binary files a/java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_SG and b/java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_SG differ diff --git a/java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_US b/java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_US index 6aa74142d..34d2f220f 100644 Binary files a/java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_US and b/java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_US differ diff --git a/resources/PhoneNumberMetaData.xml b/resources/PhoneNumberMetaData.xml index e4fd71f2e..a40c53938 100644 --- a/resources/PhoneNumberMetaData.xml +++ b/resources/PhoneNumberMetaData.xml @@ -258,8 +258,8 @@ nationalPrefix="1" internationalPrefix="011"> - [289]\d{9} - \d{7,10} + [2589]\d{9} + \d{7}(?:\d{3})? - [289]\d{9} - \d{7,10} + [2589]\d{9} + \d{7}(?:\d{3})? @@ -933,8 +933,8 @@ nationalPrefix="1" internationalPrefix="011"> - [689]\d{9} - \d{7,10} + [5689]\d{9} + \d{7}(?:\d{3})? @@ -1474,8 +1474,8 @@ nationalPrefix="1" internationalPrefix="011"> - [289]\d{9} - \d{7,10} + [2589]\d{9} + \d{7}(?:\d{3})? 246[2-9]\d{6} @@ -2182,8 +2182,8 @@ nationalPrefix="1" internationalPrefix="011"> - [489]\d{9} - \d{7,10} + [4589]\d{9} + \d{7}(?:\d{3})? @@ -2411,8 +2411,8 @@ nationalPrefix="1" internationalPrefix="011"> - [289]\d{9} - \d{7,10} + [2589]\d{9} + \d{7}(?:\d{3})? @@ -2773,7 +2773,7 @@ [2-9]\d{9}| 3\d{6} - \d{7,10} + \d{7}(?:\d{3})? @@ -2781,8 +2781,8 @@ 2(?: 04| 26| - 50| - 89 + [48]9| + 50 )| 3(?: 06| @@ -2826,8 +2826,8 @@ 2(?: 04| 26| - 50| - 89 + [48]9| + 50 )| 3(?: 06| @@ -3102,8 +3102,36 @@ - + + + + + $1 $2 + + + + [2-57]\d{4} + \d{5} + + + + (?: + 2\d| + 3[13-7]| + 4[1-5] + )\d{3} + + 21234 + + + + (?: + 5[0-68]| + 7\d + )\d{3} + + 71234 + @@ -4413,8 +4441,8 @@ nationalPrefix="1" internationalPrefix="011"> - [7-9]\d{9} - \d{7,10} + [57-9]\d{9} + \d{7}(?:\d{3})? @@ -4484,8 +4512,8 @@ nationalPrefix="1" internationalPrefix="011"> - [89]\d{9} - \d{7,10} + [589]\d{9} + \d{7}(?:\d{3})? - - 91(?: - 1(?: - [146]\d| - 2[0-5]| - 3[4-6]| - 50| - 7[2-6]| - 8[46-9] - )| - 31\d| - 4(?: - 3[0-2489]| - 7[0-3] - )| - 5(?: - 3[23]| - 7[3-5] - )| - 6(?: - 58| - 8[23] - )| - 7(?: - 5[57]| - 8[01] - )| - 8(?: - 3[45]| - 7[67] - ) - )\d{4} - + + 91[0-8]\d{6} \d{9} - 911123456 + 911234567 @@ -5240,8 +5237,29 @@ - + + + + + [2-7]\d{4} + \d{5} + + + [2-47]\d{4} + 31234 + + + [56]\d{4} + 51234 + + + + + 1\d{2}| + 999 + + 123 + @@ -5254,9 +5272,11 @@ nationalPrefixForParsing="(10(?:01|[12]0|88))" carrierCodeFormattingRule="$CC $FG"> - - $1 - + + + $1 + + [2-9]\d{5} \d{6} @@ -6075,8 +6095,8 @@ nationalPrefix="1" internationalPrefix="011"> - [489]\d{9} - \d{7,10} + [4589]\d{9} + \d{7}(?:\d{3})? @@ -6155,28 +6175,15 @@ - + - - 32 - $1 $2 $3 $4 - - - - [24]| - 3[13-79] - - $1 $2 $3 $4 - + the communications commission uses 2 3 3. Wikipedia says 3 2 3. Some use 2 6. --> - [5679] + [13-79] $1 $2 $3 $4 @@ -6186,30 +6193,14 @@ - [1-579]\d{7}| + [13-79]\d{7}| 8\d{8} \d{5,9} - (?: - 122| - 2(?: - 22| - 36| - 5[035] - )| - 3(?: - 1[0-35-8]| - 3[1-35679]| - 4\d| - 7[0-39]| - 9[1-35-7] - )| 3(?: [256]\d| 4[124-9]| @@ -6231,10 +6222,11 @@ (?: - 5[1578]| + 14| + 5[01578]| 6[28]| 7[0147-9]| - 9[0135-9] + 9[0-35-9] )\d{6} \d{8} @@ -6862,50 +6854,168 @@ + + + + [2-7] + $1 $2 + + + 1 + $1 $2 $3 + + + + + [2-7]\d{7}| + 1[89]\d{9} + + \d{8}(?:\d{3})? + + + [267][2-9]\d{6} + \d{8} + 22456789 + + + + [345]\d{7} + \d{8} + 51234567 + + + 18[01]\d{8} + \d{11} + 18001112222 + + + 19\d{9} + \d{11} + 19001112222 + + + + 1(?: + 2| + [57]\d + )\d + + \d{3,4} + 123 + - + - [689]\d{9} - \d{7,10} + [5689]\d{9} + \d{7}(?:\d{3})? + 671(?: - 3\d{2}| - 47\d| - 56\d| - 6[3-5]\d| + 3(?: + 00| + 3[39]| + 4[349]| + 55| + 6[26] + )| + 4(?: + 56| + 7[1-9]| + 8[23678] + )| + 5(?: + 55| + 6[2-5]| + 88 + )| + 6(?: + 3[2-578]| + 4[24-9]| + 5[34]| + 78| + 8[5-9] + )| 7(?: - 3\d| - 89 + [079]7| + 2[0167]| + 3[45]| + 8[789] + )| + 8(?: + [2-5789]8| + 6[48] )| - 828 + 9(?: + 2[29]| + 6[79]| + 7[179]| + 8[789]| + 9[78] + ) )\d{4} - 6713123456 + 6713001234 671(?: - 3\d{2}| - 47\d| - 56\d| - 6[3-5]\d| + 3(?: + 00| + 3[39]| + 4[349]| + 55| + 6[26] + )| + 4(?: + 56| + 7[1-9]| + 8[23678] + )| + 5(?: + 55| + 6[2-5]| + 88 + )| + 6(?: + 3[2-578]| + 4[24-9]| + 5[34]| + 78| + 8[5-9] + )| 7(?: - 3\d| - 89 + [079]7| + 2[0167]| + 3[45]| + 8[789] )| - 828 + 8(?: + [2-5789]8| + 6[48] + )| + 9(?: + 2[29]| + 6[79]| + 7[179]| + 8[789]| + 9[78] + ) )\d{4} - 6713123456 + 6713001234 @@ -8078,15 +8188,24 @@ $1 $2 $3 + pattern="(1800)(\d{4,5})"> + 180 + 1800 + $1 $2 + + 18[06] 18[06]0 $1 $2 $3 - [1-9]\d{9,10} - \d{6,11} + + 1\d{7,11}| + [2-9]\d{9,10} + + \d{6,12} 1(?: - 800\d? | - 600 - )\d{6} + 600\d{6}| + 800\d{4,8} + ) - \d{10,11} + \d{8,12} 1800123456 + + + + $1 $2 + + + + 3\d{6} + \d{7} + + + 37\d{5} + 3709100 + + + 38\d{5} + 3801234 + @@ -8971,8 +9108,8 @@ nationalPrefix="1" internationalPrefix="011"> - [89]\d{9} - \d{7,10} + [589]\d{9} + \d{7}(?:\d{3})? @@ -10241,8 +10378,43 @@ + + nationalPrefix="0" nationalPrefixFormattingRule="$NP$FG"> + + + $1 + + + + [2-689]\d{4} + \d{5} + + + + (?: + [234]\d| + 50| + 8[1-5] + )\d{3} + + 31234 + + + [69]\d{4} + 61234 + + + + 10(?: + [0-8]| + 5[01259] + )| + 99[234] + + \d{3,4} + 992 + @@ -10280,8 +10452,8 @@ nationalPrefix="1" internationalPrefix="011"> - [89]\d{9} - \d{7,10} + [589]\d{9} + \d{7}(?:\d{3})? @@ -10668,8 +10840,8 @@ nationalPrefix="1" internationalPrefix="011"> - [389]\d{9} - \d{7,10} + [3589]\d{9} + \d{7}(?:\d{3})? @@ -11026,8 +11198,8 @@ nationalPrefix="1" internationalPrefix="011"> - [789]\d{9} - \d{7,10} + [5789]\d{9} + \d{7}(?:\d{3})? @@ -12393,7 +12565,7 @@ [12]\d{7,9}| [57-9]\d{7} - \d{8,10} + \d{6,10} - [689]\d{9} - \d{7,10} + [5689]\d{9} + \d{7}(?:\d{3})? @@ -12559,61 +12731,47 @@ - - [2-48] $1 $2 $3 $4 - - [2-7] - $1 $2 $3 - - - [2-4]\d{6,7}| - [5-7]\d{6}| - 8\d{7} - - \d{7,8} + [2-48]\d{7} + \d{8} - 5(?: - 1[035]| - 2[0-69]| - 3[0348]| - 4[468]| - 5[02-467]| - 6[39]| - 7[4-69] - )\d{4}| - [2-4]5\d{6} + 25[08]\d{5}| + 35\d{6}| + 45[1-7]\d{5} 35123456 (?: - [23][0-4]| - 4[3-5]| - 6\d| - 7[0-7] - )\d{5}| - (?: - 2[27]| - 3[367]| - 4[467] - )\d{6} + 2(?: + 2\d| + 70 + )| + 3(?: + 3\d| + 6[1-36]| + 7[1-3] + )| + 4(?: + 4\d| + 6[0457-9]| + 7[4-9] + ) + )\d{5} 22123456 800\d{5} - \d{8} 80012345 @@ -12624,8 +12782,8 @@ nationalPrefix="1" internationalPrefix="011"> - [689]\d{9} - \d{7,10} + [5689]\d{9} + \d{7}(?:\d{3})? 664491\d{4} @@ -13744,9 +13902,10 @@ - - + + + [489] @@ -13765,25 +13924,17 @@ \d{5}(?:\d{3})? - + - 0\d{4}| (?: 2[1-4]| 3[1-3578]| 5[1-35-7]| 6[1-4679]| - 7\d - )\d{6}| - 81(?: - 0(?: - 0[7-9]| - 1\d - )| - 5\d{2} - )\d{3} + 7[0-8] + )\d{6} + \d{8} 21234567 @@ -13821,6 +13972,20 @@ \d{8} 88012345 + + + + 0\d{4}| + 81(?: + 0(?: + 0[7-9]| + 1\d + )| + 5\d{2} + )\d{3} + + 01234 + @@ -14736,8 +14901,8 @@ nationalPrefix="1" internationalPrefix="011"> - [789]\d{9} - \d{7,10} + [5789]\d{9} + \d{7}(?:\d{3})? @@ -15964,6 +16129,73 @@ + + + + + + + 0\d{4}| + [4789]\d{7} + + \d{5}(?:\d{3})? + + + 79\d{6} + \d{8} + 79123456 + + + + + (?: + 4[015-8]| + 9\d + )\d{6} + + \d{8} + 41234567 + + + 80[01]\d{5} + \d{8} + 80012345 + + + 82[09]\d{5} + \d{8} + 82012345 + + + + 810(?: + 0[0-6]| + [2-8]\d + )\d{3} + + \d{8} + 81021234 + + + 880\d{5} + \d{8} + 88012345 + + + + 0\d{4}| + 81(?: + 0(?: + 0[7-9]| + 1\d + )| + 5\d{2} + )\d{3} + + 01234 + + + + + + + [27] + $1 $2 + + + [89] + $1 $2 + + + [89] + $1 $2 $3 + + + + + [27]\d{7}| + [89]\d{6}(?:\d{4})? + + + \d{7,8}| + \d{11} + + + + + 2[1-6]\d{6} + \d{8} + 21234567 + + + 7\d{7} + \d{8} + 70123456 + + + + 800\d{4}(?:\d{4})? + \d{7}(?:\d{4})? + 8001234 + + + + 900\d{4}(?:\d{4})? + \d{7}(?:\d{4})? + 9001234 + @@ -16417,8 +16699,8 @@ nationalPrefix="1" internationalPrefix="011"> - [689]\d{9} - \d{7,10} + [5689]\d{9} + \d{7}(?:\d{3})? @@ -16910,11 +17192,11 @@ \d{10} 5012345678 - + 512\d{7} \d{10} 5123456789 - + 800\d{7} \d{10} @@ -16942,8 +17224,8 @@ nationalPrefix="1" internationalPrefix="011"> - [89]\d{9} - \d{7,10} + [589]\d{9} + \d{7}(?:\d{3})? @@ -17418,7 +17700,7 @@ [2-9]\d{9} - \d{7,10} + \d{7}(?:\d{3})? @@ -17459,7 +17741,7 @@ 0[1-57-9]| 1[0235-8]| 20| - 3[04]| + 3[014]| 4[01]| 5[19]| 6[1-37]| @@ -17551,7 +17833,7 @@ 0[1-57-9]| 1[0235-8]| 20| - 3[04]| + 3[014]| 4[01]| 5[19]| 6[1-37]| @@ -17707,19 +17989,8 @@ nationalPrefix="1" internationalPrefix="011"> - - (?: - 784| - 8(?: - 00| - 66| - 77| - 88 - )| - 900 - )[2-9]\d{6} - - \d{7,10} + [5789]\d{9} + \d{7}(?:\d{3})? @@ -17857,19 +18128,8 @@ nationalPrefix="1" internationalPrefix="011"> - - (?: - 284| - 8(?: - 00| - 66| - 77| - 88 - )| - 900 - )[2-9]\d{6} - - \d{7,10} + [2589]\d{9} + \d{7}(?:\d{3})? @@ -17946,27 +18206,25 @@ nationalPrefix="1" internationalPrefix="011"> + [3589]\d{9} + \d{7}(?:\d{3})? + + 340(?: 6[49]2| 7[17]\d - )\d{4}| - (?: - 8(?: - 00| - 66| - 77| - 88 - )| - 900 - )[2-9]\d{6} + )\d{4} - \d{7,10} - - 3406421234 + + 340(?: + 6[49]2| + 7[17]\d + )\d{4} + 3406421234 diff --git a/resources/PhoneNumberMetaDataForTesting.xml b/resources/PhoneNumberMetaDataForTesting.xml index 81969118f..0293daeac 100644 --- a/resources/PhoneNumberMetaDataForTesting.xml +++ b/resources/PhoneNumberMetaDataForTesting.xml @@ -670,7 +670,11 @@ [13689]\d{7,10} - \d{8,11} + + + \d{8}| + \d{10,11} + [36]\d{7} @@ -710,7 +714,7 @@ [13-9]\d{9}|2[0-35-9]\d{8} - \d{7,10} + \d{7}(?:\d{3})? 1234567890