Project import
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..8d9424a
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,21 @@
+Authors ordered by first contribution.
+
+SungMin Ha (ishtar, zen.isis@gmail.com)
+Hyuk Hur (http://hyukhur.tumblr.com)
+
+Cliff Rowley (cliffrowley@gmail.com)
+ - Missing return value in formatInOriginalFormat:regionCallingFrom:error
+ - Compatibility with iOS versions prior to 6.x
+
+Aaron Wojnowski (aaronwojnowski@gmail.com)
+ - Remove extra r from the countryCodeFromRegionCode method name.
+
+stonyw
+ - Handle char @ when normalize any strings, eg email
+
+Yosi Taguri (http://ahhhpah.com)
+ - Failed tests are down to 18 for [ AsYouTypeFormatter ]
+
+Nils Hayat (http://nilsou.com)
+ - Help to update cocoapods
+ - Added -[NBPhoneNumberUtil parseWithPhoneCarrierRegion:error:] to parse a number using the phone's carrier country code
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d9a10c0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,176 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..532bd0a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,76 @@
+# libPhoneNumber for iOS (ARC)
+
+* NBPhoneNumber, NBNumberFormat, NBPhoneNumberDesc, NBPhoneMetaData (Metadata classes)
+
+* NBPhoneNumberUtil (from phonenumberutil.js)
+* NBAsYouTypeFormatter
+
+## Install with CocoaPods
+### Use [CocoaPods](http://cocoapods.org/?q=libPhoneNumber-iOS)
+
+## Install without CocoaPods
+### Add source files to your projects from libPhoneNumber
+ - NBPhoneNumberUtil.h, .m
+ - NBAsYouTypeFormatter.h, .m
+
+ - NBNumberFormat.h, .m
+ - NBPhoneNumber.h, .m
+ - NBPhoneNumberDesc.h, .m
+ - NBPhoneNumberDefines.h
+
+ - NBPhoneNumberMetadata.h, .m
+ - NBPhoneNumberMetadataForTesting.h, .m
+
+ - Add "NBPhoneNumberMetadata.plist" and "NBPhoneNumberMetadataForTesting.plist" to bundle resources
+ - Add "CoreTelephony.framework"
+
+ See sample test code from "libPhoneNumber-iOS / libPhoneNumberTests / libPhoneNumberTests.m"
+
+## Sample Usage
+ NBPhoneNumberUtil *phoneUtil = [NBPhoneNumberUtil sharedInstance];
+
+ NSError *aError = nil;
+ NBPhoneNumber *myNumber = [phoneUtil parse:@"6766077303" defaultRegion:@"AT" error:&aError];
+
+ if (aError == nil) {
+ // Should check error
+ NSLog(@"isValidPhoneNumber ? [%@]", [phoneUtil isValidNumber:myNumber] ? @"YES":@"NO");
+ NSLog(@"E164 : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatE164
+ error:&aError]);
+ NSLog(@"INTERNATIONAL : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL
+ error:&aError]);
+ NSLog(@"NATIONAL : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatNATIONAL
+ error:&aError]);
+ NSLog(@"RFC3966 : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatRFC3966
+ error:&aError]);
+ }
+ else {
+ NSLog(@"Error : %@", [aError localizedDescription]);
+ }
+
+ NSLog (@"extractCountryCode [%ld]", [phoneUtil extractCountryCode:@"823213123123"
+ nationalNumber:nil]);
+
+ NSString *res = nil;
+ UInt32 dRes = [phoneUtil extractCountryCode:@"823213123123" nationalNumber:&res];
+
+ NSLog (@"extractCountryCode [%lu] [%@]", dRes, res);
+
+
+### Visit http://code.google.com/p/libphonenumber/ for more information
+#### or zen.isis@gmail.com
+
+## Metadata managing (updating metadata)
+#### Step1. Fetch "metadata.js" and "metadatafortesting.js" from Repositories
+ svn checkout http://libphonenumber.googlecode.com/svn/trunk/ libphonenumber-read-only
+
+#### Step2. Convert Javascript Object to JSON using PHP scripts
+ Output - "PhoneNumberMetaData.json" and "PhoneNumberMetaDataForTesting.json"
+
+#### Step3. Generate binary file from NBPhoneMetaDataGenerator
+ Output - "NBPhoneNumberMetadata.plist" and "NBPhoneNumberMetadataForTesting.plist"
+
+#### Step4. Update exists "NBPhoneNumberMetadata.plist" and "NBPhoneNumberMetadataForTesting.plist" files
+
+## Porting Rules
+* **Remain** javascript libPhonenumber code logic (and comments etc) as possible for maintenance with *.js
diff --git a/libPhoneNumber.xcodeproj/project.pbxproj b/libPhoneNumber.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..609cdb0
--- /dev/null
+++ b/libPhoneNumber.xcodeproj/project.pbxproj
@@ -0,0 +1,699 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 29F3A15D17B98AE1005D8E07 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29F3A15C17B98AE1005D8E07 /* CoreTelephony.framework */; };
+ 29F3A15E17B98B3C005D8E07 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29F3A15C17B98AE1005D8E07 /* CoreTelephony.framework */; };
+ 8F04BE90176F062500076CB4 /* NBAsYouTypeFormatterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = FD57B66C16E5B71F000772AF /* NBAsYouTypeFormatterTest.m */; };
+ 8FE047B5174389F300CCA610 /* NBAsYouTypeFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = FD4C786916DB62AC00473849 /* NBAsYouTypeFormatter.m */; };
+ D39D45BE17D7AA020051A471 /* NBAsYouTypeFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = FD4C786916DB62AC00473849 /* NBAsYouTypeFormatter.m */; };
+ FD0BD7781679DDA700B19065 /* NBPhoneNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = FD0BD7771679DDA600B19065 /* NBPhoneNumber.m */; };
+ FD7A0621167715A0004BBEB6 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD7A0620167715A0004BBEB6 /* UIKit.framework */; };
+ FD7A0623167715A0004BBEB6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD7A0622167715A0004BBEB6 /* Foundation.framework */; };
+ FD7A0625167715A0004BBEB6 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD7A0624167715A0004BBEB6 /* CoreGraphics.framework */; };
+ FD7A062B167715A0004BBEB6 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = FD7A0629167715A0004BBEB6 /* InfoPlist.strings */; };
+ FD7A062D167715A0004BBEB6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A062C167715A0004BBEB6 /* main.m */; };
+ FD7A0633167715A0004BBEB6 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = FD7A0632167715A0004BBEB6 /* Default.png */; };
+ FD7A0635167715A0004BBEB6 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FD7A0634167715A0004BBEB6 /* Default@2x.png */; };
+ FD7A0637167715A0004BBEB6 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FD7A0636167715A0004BBEB6 /* Default-568h@2x.png */; };
+ FD7A063F167715A1004BBEB6 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD7A063E167715A1004BBEB6 /* SenTestingKit.framework */; };
+ FD7A0640167715A1004BBEB6 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD7A0620167715A0004BBEB6 /* UIKit.framework */; };
+ FD7A0641167715A1004BBEB6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD7A0622167715A0004BBEB6 /* Foundation.framework */; };
+ FD7A0649167715A1004BBEB6 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = FD7A0647167715A1004BBEB6 /* InfoPlist.strings */; };
+ FD7A064C167715A1004BBEB6 /* NBPhoneNumberUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A064B167715A1004BBEB6 /* NBPhoneNumberUtilTests.m */; };
+ FD7A0657167715B2004BBEB6 /* NBPhoneNumberUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A0656167715B2004BBEB6 /* NBPhoneNumberUtil.m */; };
+ FD7A0658167715B2004BBEB6 /* NBPhoneNumberUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A0656167715B2004BBEB6 /* NBPhoneNumberUtil.m */; };
+ FD7A065F167715FD004BBEB6 /* NBNumberFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A065E167715FD004BBEB6 /* NBNumberFormat.m */; };
+ FD7A0660167715FD004BBEB6 /* NBNumberFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A065E167715FD004BBEB6 /* NBNumberFormat.m */; };
+ FD7A066316771A54004BBEB6 /* NBPhoneNumberDesc.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A066216771A54004BBEB6 /* NBPhoneNumberDesc.m */; };
+ FD7A066416771A54004BBEB6 /* NBPhoneNumberDesc.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A066216771A54004BBEB6 /* NBPhoneNumberDesc.m */; };
+ FD7A066716771AFD004BBEB6 /* NBPhoneMetaData.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A066616771AFD004BBEB6 /* NBPhoneMetaData.m */; };
+ FD7A066816771AFD004BBEB6 /* NBPhoneMetaData.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A066616771AFD004BBEB6 /* NBPhoneMetaData.m */; };
+ FD9E3ADC169E5176007E06CC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD7A0622167715A0004BBEB6 /* Foundation.framework */; };
+ FD9E3AE7169E51A2007E06CC /* NBNumberFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A065E167715FD004BBEB6 /* NBNumberFormat.m */; };
+ FD9E3AE8169E51A2007E06CC /* NBPhoneMetaData.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A066616771AFD004BBEB6 /* NBPhoneMetaData.m */; };
+ FD9E3AE9169E51A2007E06CC /* NBPhoneNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = FD0BD7771679DDA600B19065 /* NBPhoneNumber.m */; };
+ FD9E3AEA169E51A2007E06CC /* NBPhoneNumberDesc.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A066216771A54004BBEB6 /* NBPhoneNumberDesc.m */; };
+ FD9E3AEB169E51A2007E06CC /* NBPhoneNumberUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A0656167715B2004BBEB6 /* NBPhoneNumberUtil.m */; };
+ FD9E3AEE169E51D1007E06CC /* NBNumberFormat.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD7A065D167715FD004BBEB6 /* NBNumberFormat.h */; };
+ FD9E3AEF169E51D1007E06CC /* NBPhoneMetaData.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD7A066516771AFD004BBEB6 /* NBPhoneMetaData.h */; };
+ FD9E3AF0169E51D1007E06CC /* NBPhoneNumber.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD0BD7761679DDA600B19065 /* NBPhoneNumber.h */; };
+ FD9E3AF1169E51D1007E06CC /* NBPhoneNumberDefines.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = FDBCAD2016954FE4005E0334 /* NBPhoneNumberDefines.h */; };
+ FD9E3AF2169E51D1007E06CC /* NBPhoneNumberDesc.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD7A066116771A54004BBEB6 /* NBPhoneNumberDesc.h */; };
+ FD9E3AF3169E51D1007E06CC /* NBPhoneNumberUtil.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = FD7A0655167715B2004BBEB6 /* NBPhoneNumberUtil.h */; };
+ FD9E3AF6169E62B6007E06CC /* NBPhoneMetaDataGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = FD7A066E167736BD004BBEB6 /* NBPhoneMetaDataGenerator.m */; };
+ FDAACB55167F3F11002DB4D4 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD7A0624167715A0004BBEB6 /* CoreGraphics.framework */; };
+ FDAE1B3016CE2C1C007EB0ED /* PhoneNumberMetaData.json in Resources */ = {isa = PBXBuildFile; fileRef = FDAE1B2E16CE2C1C007EB0ED /* PhoneNumberMetaData.json */; };
+ FDAE1B3116CE2C1C007EB0ED /* PhoneNumberMetaData.json in Resources */ = {isa = PBXBuildFile; fileRef = FDAE1B2E16CE2C1C007EB0ED /* PhoneNumberMetaData.json */; };
+ FDAE1B3216CE2C1C007EB0ED /* PhoneNumberMetaDataForTesting.json in Resources */ = {isa = PBXBuildFile; fileRef = FDAE1B2F16CE2C1C007EB0ED /* PhoneNumberMetaDataForTesting.json */; };
+ FDAE1B3316CE2C1C007EB0ED /* PhoneNumberMetaDataForTesting.json in Resources */ = {isa = PBXBuildFile; fileRef = FDAE1B2F16CE2C1C007EB0ED /* PhoneNumberMetaDataForTesting.json */; };
+ FDAE1B3616CE2C92007EB0ED /* NBPhoneNumberMetadata.plist in Resources */ = {isa = PBXBuildFile; fileRef = FDAE1B3416CE2C92007EB0ED /* NBPhoneNumberMetadata.plist */; };
+ FDAE1B3716CE2C92007EB0ED /* NBPhoneNumberMetadata.plist in Resources */ = {isa = PBXBuildFile; fileRef = FDAE1B3416CE2C92007EB0ED /* NBPhoneNumberMetadata.plist */; };
+ FDAE1B3816CE2C92007EB0ED /* NBPhoneNumberMetadataForTesting.plist in Resources */ = {isa = PBXBuildFile; fileRef = FDAE1B3516CE2C92007EB0ED /* NBPhoneNumberMetadataForTesting.plist */; };
+ FDAE1B3916CE2C92007EB0ED /* NBPhoneNumberMetadataForTesting.plist in Resources */ = {isa = PBXBuildFile; fileRef = FDAE1B3516CE2C92007EB0ED /* NBPhoneNumberMetadataForTesting.plist */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ FD7A0642167715A1004BBEB6 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = FD7A0613167715A0004BBEB6 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = FD7A061B167715A0004BBEB6;
+ remoteInfo = libPhoneNumber;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ FD9E3AD9169E5176007E06CC /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "include/${PRODUCT_NAME}";
+ dstSubfolderSpec = 16;
+ files = (
+ FD9E3AEE169E51D1007E06CC /* NBNumberFormat.h in CopyFiles */,
+ FD9E3AEF169E51D1007E06CC /* NBPhoneMetaData.h in CopyFiles */,
+ FD9E3AF0169E51D1007E06CC /* NBPhoneNumber.h in CopyFiles */,
+ FD9E3AF1169E51D1007E06CC /* NBPhoneNumberDefines.h in CopyFiles */,
+ FD9E3AF2169E51D1007E06CC /* NBPhoneNumberDesc.h in CopyFiles */,
+ FD9E3AF3169E51D1007E06CC /* NBPhoneNumberUtil.h in CopyFiles */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 29F3A15C17B98AE1005D8E07 /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
+ 4D43EF831740825100C24FF3 /* libPhoneNumber-iOS.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = "libPhoneNumber-iOS.podspec"; sourceTree = SOURCE_ROOT; };
+ FD0BD7761679DDA600B19065 /* NBPhoneNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBPhoneNumber.h; sourceTree = "<group>"; };
+ FD0BD7771679DDA600B19065 /* NBPhoneNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBPhoneNumber.m; sourceTree = "<group>"; };
+ FD2014DC169A8A82003491D9 /* index.php */ = {isa = PBXFileReference; lastKnownFileType = text.script.php; path = index.php; sourceTree = "<group>"; };
+ FD2014DD169A8A82003491D9 /* libPhoneNumberGenerator.php */ = {isa = PBXFileReference; lastKnownFileType = text.script.php; path = libPhoneNumberGenerator.php; sourceTree = "<group>"; };
+ FD4C786816DB62AC00473849 /* NBAsYouTypeFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBAsYouTypeFormatter.h; sourceTree = "<group>"; };
+ FD4C786916DB62AC00473849 /* NBAsYouTypeFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBAsYouTypeFormatter.m; sourceTree = "<group>"; };
+ FD57B66B16E5B71F000772AF /* NBAsYouTypeFormatterTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBAsYouTypeFormatterTest.h; sourceTree = "<group>"; };
+ FD57B66C16E5B71F000772AF /* NBAsYouTypeFormatterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBAsYouTypeFormatterTest.m; sourceTree = "<group>"; };
+ FD7A061C167715A0004BBEB6 /* libPhoneNumber.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = libPhoneNumber.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ FD7A0620167715A0004BBEB6 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ FD7A0622167715A0004BBEB6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ FD7A0624167715A0004BBEB6 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ FD7A0628167715A0004BBEB6 /* libPhoneNumber-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "libPhoneNumber-Info.plist"; sourceTree = "<group>"; };
+ FD7A062A167715A0004BBEB6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ FD7A062C167715A0004BBEB6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ FD7A062E167715A0004BBEB6 /* libPhoneNumber-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "libPhoneNumber-Prefix.pch"; sourceTree = "<group>"; };
+ FD7A0632167715A0004BBEB6 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
+ FD7A0634167715A0004BBEB6 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = "<group>"; };
+ FD7A0636167715A0004BBEB6 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
+ FD7A063D167715A1004BBEB6 /* libPhoneNumberTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = libPhoneNumberTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
+ FD7A063E167715A1004BBEB6 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
+ FD7A0646167715A1004BBEB6 /* libPhoneNumberTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "libPhoneNumberTests-Info.plist"; sourceTree = "<group>"; };
+ FD7A0648167715A1004BBEB6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ FD7A064A167715A1004BBEB6 /* NBPhoneNumberUtilTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NBPhoneNumberUtilTests.h; sourceTree = "<group>"; };
+ FD7A064B167715A1004BBEB6 /* NBPhoneNumberUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NBPhoneNumberUtilTests.m; sourceTree = "<group>"; };
+ FD7A0655167715B2004BBEB6 /* NBPhoneNumberUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBPhoneNumberUtil.h; sourceTree = "<group>"; };
+ FD7A0656167715B2004BBEB6 /* NBPhoneNumberUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBPhoneNumberUtil.m; sourceTree = "<group>"; };
+ FD7A065D167715FD004BBEB6 /* NBNumberFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBNumberFormat.h; sourceTree = "<group>"; };
+ FD7A065E167715FD004BBEB6 /* NBNumberFormat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBNumberFormat.m; sourceTree = "<group>"; };
+ FD7A066116771A54004BBEB6 /* NBPhoneNumberDesc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBPhoneNumberDesc.h; sourceTree = "<group>"; };
+ FD7A066216771A54004BBEB6 /* NBPhoneNumberDesc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBPhoneNumberDesc.m; sourceTree = "<group>"; };
+ FD7A066516771AFD004BBEB6 /* NBPhoneMetaData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBPhoneMetaData.h; sourceTree = "<group>"; };
+ FD7A066616771AFD004BBEB6 /* NBPhoneMetaData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBPhoneMetaData.m; sourceTree = "<group>"; };
+ FD7A066D167736BD004BBEB6 /* NBPhoneMetaDataGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NBPhoneMetaDataGenerator.h; sourceTree = "<group>"; };
+ FD7A066E167736BD004BBEB6 /* NBPhoneMetaDataGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NBPhoneMetaDataGenerator.m; sourceTree = "<group>"; };
+ FD9E3ADB169E5176007E06CC /* liblibPhoneNumberiOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = liblibPhoneNumberiOS.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ FD9E3ADF169E5176007E06CC /* libPhoneNumberiOS-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "libPhoneNumberiOS-Prefix.pch"; sourceTree = "<group>"; };
+ FDAE1B2E16CE2C1C007EB0ED /* PhoneNumberMetaData.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = PhoneNumberMetaData.json; sourceTree = "<group>"; };
+ FDAE1B2F16CE2C1C007EB0ED /* PhoneNumberMetaDataForTesting.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = PhoneNumberMetaDataForTesting.json; sourceTree = "<group>"; };
+ FDAE1B3416CE2C92007EB0ED /* NBPhoneNumberMetadata.plist */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = NBPhoneNumberMetadata.plist; sourceTree = "<group>"; };
+ FDAE1B3516CE2C92007EB0ED /* NBPhoneNumberMetadataForTesting.plist */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = NBPhoneNumberMetadataForTesting.plist; sourceTree = "<group>"; };
+ FDBCAD2016954FE4005E0334 /* NBPhoneNumberDefines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NBPhoneNumberDefines.h; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ FD7A0619167715A0004BBEB6 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 29F3A15D17B98AE1005D8E07 /* CoreTelephony.framework in Frameworks */,
+ FD7A0621167715A0004BBEB6 /* UIKit.framework in Frameworks */,
+ FD7A0623167715A0004BBEB6 /* Foundation.framework in Frameworks */,
+ FD7A0625167715A0004BBEB6 /* CoreGraphics.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ FD7A0639167715A1004BBEB6 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ FDAACB55167F3F11002DB4D4 /* CoreGraphics.framework in Frameworks */,
+ FD7A063F167715A1004BBEB6 /* SenTestingKit.framework in Frameworks */,
+ FD7A0640167715A1004BBEB6 /* UIKit.framework in Frameworks */,
+ FD7A0641167715A1004BBEB6 /* Foundation.framework in Frameworks */,
+ 29F3A15E17B98B3C005D8E07 /* CoreTelephony.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ FD9E3AD8169E5176007E06CC /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ FD9E3ADC169E5176007E06CC /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ FD0F11AD169AC2AB008DF508 /* Classes */ = {
+ isa = PBXGroup;
+ children = (
+ FD4C786816DB62AC00473849 /* NBAsYouTypeFormatter.h */,
+ FD4C786916DB62AC00473849 /* NBAsYouTypeFormatter.m */,
+ FD7A065D167715FD004BBEB6 /* NBNumberFormat.h */,
+ FD7A065E167715FD004BBEB6 /* NBNumberFormat.m */,
+ FD7A066516771AFD004BBEB6 /* NBPhoneMetaData.h */,
+ FD7A066616771AFD004BBEB6 /* NBPhoneMetaData.m */,
+ FD0BD7761679DDA600B19065 /* NBPhoneNumber.h */,
+ FD0BD7771679DDA600B19065 /* NBPhoneNumber.m */,
+ FDBCAD2016954FE4005E0334 /* NBPhoneNumberDefines.h */,
+ FD7A066116771A54004BBEB6 /* NBPhoneNumberDesc.h */,
+ FD7A066216771A54004BBEB6 /* NBPhoneNumberDesc.m */,
+ FD7A0655167715B2004BBEB6 /* NBPhoneNumberUtil.h */,
+ FD7A0656167715B2004BBEB6 /* NBPhoneNumberUtil.m */,
+ );
+ name = Classes;
+ sourceTree = "<group>";
+ };
+ FD2014DF169A8A88003491D9 /* Javascript Object to JSON Converter (PHP) */ = {
+ isa = PBXGroup;
+ children = (
+ FD2014DC169A8A82003491D9 /* index.php */,
+ FD2014DD169A8A82003491D9 /* libPhoneNumberGenerator.php */,
+ );
+ name = "Javascript Object to JSON Converter (PHP)";
+ path = libPhoneNumberTests;
+ sourceTree = SOURCE_ROOT;
+ };
+ FD7A0611167715A0004BBEB6 = {
+ isa = PBXGroup;
+ children = (
+ FD7A061F167715A0004BBEB6 /* Frameworks */,
+ FD7A0626167715A0004BBEB6 /* libPhoneNumber */,
+ FD7A0644167715A1004BBEB6 /* libPhoneNumber UnitTest */,
+ FD9E3ADD169E5176007E06CC /* libPhoneNumberiOS */,
+ FD7A061D167715A0004BBEB6 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ FD7A061D167715A0004BBEB6 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ FD7A061C167715A0004BBEB6 /* libPhoneNumber.app */,
+ FD7A063D167715A1004BBEB6 /* libPhoneNumberTests.octest */,
+ FD9E3ADB169E5176007E06CC /* liblibPhoneNumberiOS.a */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ FD7A061F167715A0004BBEB6 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ FD7A0624167715A0004BBEB6 /* CoreGraphics.framework */,
+ FD7A0622167715A0004BBEB6 /* Foundation.framework */,
+ FD7A063E167715A1004BBEB6 /* SenTestingKit.framework */,
+ FD7A0620167715A0004BBEB6 /* UIKit.framework */,
+ 29F3A15C17B98AE1005D8E07 /* CoreTelephony.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ FD7A0626167715A0004BBEB6 /* libPhoneNumber */ = {
+ isa = PBXGroup;
+ children = (
+ 4D43EF831740825100C24FF3 /* libPhoneNumber-iOS.podspec */,
+ FD0F11AD169AC2AB008DF508 /* Classes */,
+ FDB5E108169BE40C00AB88AE /* Metadata */,
+ FD7A0627167715A0004BBEB6 /* Supporting Files */,
+ );
+ path = libPhoneNumber;
+ sourceTree = "<group>";
+ };
+ FD7A0627167715A0004BBEB6 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ FD2014DF169A8A88003491D9 /* Javascript Object to JSON Converter (PHP) */,
+ FD7A066D167736BD004BBEB6 /* NBPhoneMetaDataGenerator.h */,
+ FD7A066E167736BD004BBEB6 /* NBPhoneMetaDataGenerator.m */,
+ FD7A062C167715A0004BBEB6 /* main.m */,
+ FD7A062E167715A0004BBEB6 /* libPhoneNumber-Prefix.pch */,
+ FD7A0628167715A0004BBEB6 /* libPhoneNumber-Info.plist */,
+ FD7A0636167715A0004BBEB6 /* Default-568h@2x.png */,
+ FD7A0632167715A0004BBEB6 /* Default.png */,
+ FD7A0634167715A0004BBEB6 /* Default@2x.png */,
+ FD7A0629167715A0004BBEB6 /* InfoPlist.strings */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ FD7A0644167715A1004BBEB6 /* libPhoneNumber UnitTest */ = {
+ isa = PBXGroup;
+ children = (
+ FD7A064A167715A1004BBEB6 /* NBPhoneNumberUtilTests.h */,
+ FD7A064B167715A1004BBEB6 /* NBPhoneNumberUtilTests.m */,
+ FD57B66B16E5B71F000772AF /* NBAsYouTypeFormatterTest.h */,
+ FD57B66C16E5B71F000772AF /* NBAsYouTypeFormatterTest.m */,
+ FD7A0645167715A1004BBEB6 /* Supporting Files */,
+ );
+ name = "libPhoneNumber UnitTest";
+ path = libPhoneNumberTests;
+ sourceTree = SOURCE_ROOT;
+ };
+ FD7A0645167715A1004BBEB6 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ FD7A0647167715A1004BBEB6 /* InfoPlist.strings */,
+ FD7A0646167715A1004BBEB6 /* libPhoneNumberTests-Info.plist */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ FD9E3ADD169E5176007E06CC /* libPhoneNumberiOS */ = {
+ isa = PBXGroup;
+ children = (
+ FD9E3ADE169E5176007E06CC /* Supporting Files */,
+ );
+ path = libPhoneNumberiOS;
+ sourceTree = "<group>";
+ };
+ FD9E3ADE169E5176007E06CC /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ FD9E3ADF169E5176007E06CC /* libPhoneNumberiOS-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ FDB5E108169BE40C00AB88AE /* Metadata */ = {
+ isa = PBXGroup;
+ children = (
+ FDAE1B2E16CE2C1C007EB0ED /* PhoneNumberMetaData.json */,
+ FDAE1B2F16CE2C1C007EB0ED /* PhoneNumberMetaDataForTesting.json */,
+ FDAE1B3416CE2C92007EB0ED /* NBPhoneNumberMetadata.plist */,
+ FDAE1B3516CE2C92007EB0ED /* NBPhoneNumberMetadataForTesting.plist */,
+ );
+ name = Metadata;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ FD7A061B167715A0004BBEB6 /* libPhoneNumber */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = FD7A064F167715A1004BBEB6 /* Build configuration list for PBXNativeTarget "libPhoneNumber" */;
+ buildPhases = (
+ FD7A0618167715A0004BBEB6 /* Sources */,
+ FD7A0619167715A0004BBEB6 /* Frameworks */,
+ FD7A061A167715A0004BBEB6 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = libPhoneNumber;
+ productName = libPhoneNumber;
+ productReference = FD7A061C167715A0004BBEB6 /* libPhoneNumber.app */;
+ productType = "com.apple.product-type.application";
+ };
+ FD7A063C167715A1004BBEB6 /* libPhoneNumberTests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = FD7A0652167715A1004BBEB6 /* Build configuration list for PBXNativeTarget "libPhoneNumberTests" */;
+ buildPhases = (
+ FD7A0638167715A1004BBEB6 /* Sources */,
+ FD7A0639167715A1004BBEB6 /* Frameworks */,
+ FD7A063A167715A1004BBEB6 /* Resources */,
+ FD7A063B167715A1004BBEB6 /* ShellScript */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ FD7A0643167715A1004BBEB6 /* PBXTargetDependency */,
+ );
+ name = libPhoneNumberTests;
+ productName = libPhoneNumberTests;
+ productReference = FD7A063D167715A1004BBEB6 /* libPhoneNumberTests.octest */;
+ productType = "com.apple.product-type.bundle.ocunit-test";
+ };
+ FD9E3ADA169E5176007E06CC /* libPhoneNumberiOS */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = FD9E3AE4169E5176007E06CC /* Build configuration list for PBXNativeTarget "libPhoneNumberiOS" */;
+ buildPhases = (
+ FD9E3AD7169E5176007E06CC /* Sources */,
+ FD9E3AD8169E5176007E06CC /* Frameworks */,
+ FD9E3AD9169E5176007E06CC /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = libPhoneNumberiOS;
+ productName = libPhoneNumberiOS;
+ productReference = FD9E3ADB169E5176007E06CC /* liblibPhoneNumberiOS.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ FD7A0613167715A0004BBEB6 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastTestingUpgradeCheck = 0510;
+ LastUpgradeCheck = 0510;
+ ORGANIZATIONNAME = NHN;
+ };
+ buildConfigurationList = FD7A0616167715A0004BBEB6 /* Build configuration list for PBXProject "libPhoneNumber" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = FD7A0611167715A0004BBEB6;
+ productRefGroup = FD7A061D167715A0004BBEB6 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ FD7A061B167715A0004BBEB6 /* libPhoneNumber */,
+ FD7A063C167715A1004BBEB6 /* libPhoneNumberTests */,
+ FD9E3ADA169E5176007E06CC /* libPhoneNumberiOS */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ FD7A061A167715A0004BBEB6 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ FD7A062B167715A0004BBEB6 /* InfoPlist.strings in Resources */,
+ FD7A0633167715A0004BBEB6 /* Default.png in Resources */,
+ FD7A0635167715A0004BBEB6 /* Default@2x.png in Resources */,
+ FD7A0637167715A0004BBEB6 /* Default-568h@2x.png in Resources */,
+ FDAE1B3016CE2C1C007EB0ED /* PhoneNumberMetaData.json in Resources */,
+ FDAE1B3216CE2C1C007EB0ED /* PhoneNumberMetaDataForTesting.json in Resources */,
+ FDAE1B3616CE2C92007EB0ED /* NBPhoneNumberMetadata.plist in Resources */,
+ FDAE1B3816CE2C92007EB0ED /* NBPhoneNumberMetadataForTesting.plist in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ FD7A063A167715A1004BBEB6 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ FD7A0649167715A1004BBEB6 /* InfoPlist.strings in Resources */,
+ FDAE1B3116CE2C1C007EB0ED /* PhoneNumberMetaData.json in Resources */,
+ FDAE1B3316CE2C1C007EB0ED /* PhoneNumberMetaDataForTesting.json in Resources */,
+ FDAE1B3716CE2C92007EB0ED /* NBPhoneNumberMetadata.plist in Resources */,
+ FDAE1B3916CE2C92007EB0ED /* NBPhoneNumberMetadataForTesting.plist in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ FD7A063B167715A1004BBEB6 /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ FD7A0618167715A0004BBEB6 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ FD9E3AF6169E62B6007E06CC /* NBPhoneMetaDataGenerator.m in Sources */,
+ FD7A062D167715A0004BBEB6 /* main.m in Sources */,
+ FD7A0657167715B2004BBEB6 /* NBPhoneNumberUtil.m in Sources */,
+ FD7A065F167715FD004BBEB6 /* NBNumberFormat.m in Sources */,
+ FD7A066316771A54004BBEB6 /* NBPhoneNumberDesc.m in Sources */,
+ FD7A066716771AFD004BBEB6 /* NBPhoneMetaData.m in Sources */,
+ FD0BD7781679DDA700B19065 /* NBPhoneNumber.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ FD7A0638167715A1004BBEB6 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8F04BE90176F062500076CB4 /* NBAsYouTypeFormatterTest.m in Sources */,
+ 8FE047B5174389F300CCA610 /* NBAsYouTypeFormatter.m in Sources */,
+ FD7A064C167715A1004BBEB6 /* NBPhoneNumberUtilTests.m in Sources */,
+ FD7A0658167715B2004BBEB6 /* NBPhoneNumberUtil.m in Sources */,
+ FD7A0660167715FD004BBEB6 /* NBNumberFormat.m in Sources */,
+ FD7A066416771A54004BBEB6 /* NBPhoneNumberDesc.m in Sources */,
+ FD7A066816771AFD004BBEB6 /* NBPhoneMetaData.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ FD9E3AD7169E5176007E06CC /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D39D45BE17D7AA020051A471 /* NBAsYouTypeFormatter.m in Sources */,
+ FD9E3AE7169E51A2007E06CC /* NBNumberFormat.m in Sources */,
+ FD9E3AE8169E51A2007E06CC /* NBPhoneMetaData.m in Sources */,
+ FD9E3AE9169E51A2007E06CC /* NBPhoneNumber.m in Sources */,
+ FD9E3AEA169E51A2007E06CC /* NBPhoneNumberDesc.m in Sources */,
+ FD9E3AEB169E51A2007E06CC /* NBPhoneNumberUtil.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ FD7A0643167715A1004BBEB6 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = FD7A061B167715A0004BBEB6 /* libPhoneNumber */;
+ targetProxy = FD7A0642167715A1004BBEB6 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin PBXVariantGroup section */
+ FD7A0629167715A0004BBEB6 /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ FD7A062A167715A0004BBEB6 /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ FD7A0647167715A1004BBEB6 /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ FD7A0648167715A1004BBEB6 /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ FD7A064D167715A1004BBEB6 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2";
+ IPHONEOS_DEPLOYMENT_TARGET = 6.0;
+ OTHER_CFLAGS = "-lxml2";
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ FD7A064E167715A1004BBEB6 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2";
+ IPHONEOS_DEPLOYMENT_TARGET = 6.0;
+ OTHER_CFLAGS = "-lxml2";
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ FD7A0650167715A1004BBEB6 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "libPhoneNumber/libPhoneNumber-Prefix.pch";
+ HEADER_SEARCH_PATHS = "";
+ INFOPLIST_FILE = "libPhoneNumber/libPhoneNumber-Info.plist";
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ ONLY_ACTIVE_ARCH = NO;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ FD7A0651167715A1004BBEB6 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "libPhoneNumber/libPhoneNumber-Prefix.pch";
+ HEADER_SEARCH_PATHS = "";
+ INFOPLIST_FILE = "libPhoneNumber/libPhoneNumber-Info.plist";
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+ FD7A0653167715A1004BBEB6 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/libPhoneNumber.app/libPhoneNumber";
+ FRAMEWORK_SEARCH_PATHS = (
+ "\"$(SDKROOT)/Developer/Library/Frameworks\"",
+ "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
+ );
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "libPhoneNumber/libPhoneNumber-Prefix.pch";
+ HEADER_SEARCH_PATHS = "";
+ INFOPLIST_FILE = "libPhoneNumberTests/libPhoneNumberTests-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TEST_HOST = "$(BUNDLE_LOADER)";
+ WRAPPER_EXTENSION = octest;
+ };
+ name = Debug;
+ };
+ FD7A0654167715A1004BBEB6 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/libPhoneNumber.app/libPhoneNumber";
+ FRAMEWORK_SEARCH_PATHS = (
+ "\"$(SDKROOT)/Developer/Library/Frameworks\"",
+ "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
+ );
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "libPhoneNumber/libPhoneNumber-Prefix.pch";
+ HEADER_SEARCH_PATHS = "";
+ INFOPLIST_FILE = "libPhoneNumberTests/libPhoneNumberTests-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TEST_HOST = "$(BUNDLE_LOADER)";
+ WRAPPER_EXTENSION = octest;
+ };
+ name = Release;
+ };
+ FD9E3AE5169E5176007E06CC /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ DSTROOT = /tmp/libPhoneNumberiOS.dst;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "libPhoneNumberiOS/libPhoneNumberiOS-Prefix.pch";
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Debug;
+ };
+ FD9E3AE6169E5176007E06CC /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ DSTROOT = /tmp/libPhoneNumberiOS.dst;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "libPhoneNumberiOS/libPhoneNumberiOS-Prefix.pch";
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ FD7A0616167715A0004BBEB6 /* Build configuration list for PBXProject "libPhoneNumber" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ FD7A064D167715A1004BBEB6 /* Debug */,
+ FD7A064E167715A1004BBEB6 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ FD7A064F167715A1004BBEB6 /* Build configuration list for PBXNativeTarget "libPhoneNumber" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ FD7A0650167715A1004BBEB6 /* Debug */,
+ FD7A0651167715A1004BBEB6 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ FD7A0652167715A1004BBEB6 /* Build configuration list for PBXNativeTarget "libPhoneNumberTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ FD7A0653167715A1004BBEB6 /* Debug */,
+ FD7A0654167715A1004BBEB6 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ FD9E3AE4169E5176007E06CC /* Build configuration list for PBXNativeTarget "libPhoneNumberiOS" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ FD9E3AE5169E5176007E06CC /* Debug */,
+ FD9E3AE6169E5176007E06CC /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = FD7A0613167715A0004BBEB6 /* Project object */;
+}
diff --git a/libPhoneNumber.xcodeproj/xcuserdata/miat.xcuserdatad/xcschemes/xcschememanagement.plist b/libPhoneNumber.xcodeproj/xcuserdata/miat.xcuserdatad/xcschemes/xcschememanagement.plist
new file mode 100644
index 0000000..b09430a
--- /dev/null
+++ b/libPhoneNumber.xcodeproj/xcuserdata/miat.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>SuppressBuildableAutocreation</key>
+ <dict>
+ <key>FD7A061B167715A0004BBEB6</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ <key>FD7A063C167715A1004BBEB6</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ <key>FD9E3ADA169E5176007E06CC</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ </dict>
+</dict>
+</plist>
diff --git a/libPhoneNumber/AppDelegate.h b/libPhoneNumber/AppDelegate.h
new file mode 100644
index 0000000..342ab53
--- /dev/null
+++ b/libPhoneNumber/AppDelegate.h
@@ -0,0 +1,14 @@
+//
+// AppDelegate.h
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import <UIKit/UIKit.h>
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@end
diff --git a/libPhoneNumber/AppDelegate.m b/libPhoneNumber/AppDelegate.m
new file mode 100644
index 0000000..c83a01f
--- /dev/null
+++ b/libPhoneNumber/AppDelegate.m
@@ -0,0 +1,52 @@
+//
+// AppDelegate.m
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import "AppDelegate.h"
+#import "NBPhoneMetaDataGenerator.h"
+
+@implementation AppDelegate
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ self.window.backgroundColor = [UIColor blackColor];
+ [self.window makeKeyAndVisible];
+
+ NBPhoneMetaDataGenerator *generator = [[NBPhoneMetaDataGenerator alloc] init];
+ [generator generateMetadataClasses];
+
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application
+{
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+}
+
+@end
diff --git a/libPhoneNumber/Default-568h@2x.png b/libPhoneNumber/Default-568h@2x.png
new file mode 100644
index 0000000..0891b7a
--- /dev/null
+++ b/libPhoneNumber/Default-568h@2x.png
Binary files differ
diff --git a/libPhoneNumber/Default.png b/libPhoneNumber/Default.png
new file mode 100644
index 0000000..4c8ca6f
--- /dev/null
+++ b/libPhoneNumber/Default.png
Binary files differ
diff --git a/libPhoneNumber/Default@2x.png b/libPhoneNumber/Default@2x.png
new file mode 100644
index 0000000..35b84cf
--- /dev/null
+++ b/libPhoneNumber/Default@2x.png
Binary files differ
diff --git a/libPhoneNumber/NBAsYouTypeFormatter.h b/libPhoneNumber/NBAsYouTypeFormatter.h
new file mode 100644
index 0000000..c994fd5
--- /dev/null
+++ b/libPhoneNumber/NBAsYouTypeFormatter.h
@@ -0,0 +1,21 @@
+//
+// NBAsYouTypeFormatter.h
+// libPhoneNumber
+//
+// Created by ishtar on 13. 2. 25..
+// Copyright (c) 2013년 NHN. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface NBAsYouTypeFormatter : NSObject
+
+- (id)initWithRegionCode:(NSString*)regionCode;
+- (id)initWithRegionCodeForTest:(NSString*)regionCode;
+
+- (NSString*)inputDigit:(NSString*)nextChar;
+- (NSString*)inputDigitAndRememberPosition:(NSString*)nextChar;
+- (NSInteger)getRememberedPosition;
+- (void)clear;
+
+@end
diff --git a/libPhoneNumber/NBAsYouTypeFormatter.m b/libPhoneNumber/NBAsYouTypeFormatter.m
new file mode 100644
index 0000000..742199d
--- /dev/null
+++ b/libPhoneNumber/NBAsYouTypeFormatter.m
@@ -0,0 +1,1146 @@
+//
+// NBAsYouTypeFormatter.m
+// libPhoneNumber
+//
+// Created by ishtar on 13. 2. 25..
+// Copyright (c) 2013년 NHN. All rights reserved.
+//
+
+#import "NBAsYouTypeFormatter.h"
+
+#import "NBPhoneNumberUtil.h"
+#import "NBPhoneMetaData.h"
+#import "NBNumberFormat.h"
+
+
+@interface NBAsYouTypeFormatter ()
+
+@property (nonatomic, strong, readwrite) NSString *DIGIT_PLACEHOLDER_;
+@property (nonatomic, assign, readwrite) NSString *SEPARATOR_BEFORE_NATIONAL_NUMBER_;
+@property (nonatomic, strong, readwrite) NSString *currentOutput_, *currentFormattingPattern_;
+@property (nonatomic, strong, readwrite) NSString *defaultCountry_;
+@property (nonatomic, strong, readwrite) NSString *nationalPrefixExtracted_;
+@property (nonatomic, strong, readwrite) NSMutableString *formattingTemplate_, *accruedInput_, *prefixBeforeNationalNumber_, *accruedInputWithoutFormatting_, *nationalNumber_;
+@property (nonatomic, strong, readwrite) NSRegularExpression *DIGIT_PATTERN_, *NATIONAL_PREFIX_SEPARATORS_PATTERN_, *CHARACTER_CLASS_PATTERN_, *STANDALONE_DIGIT_PATTERN_;
+@property (nonatomic, strong, readwrite) NSRegularExpression *ELIGIBLE_FORMAT_PATTERN_;
+@property (nonatomic, assign, readwrite) BOOL ableToFormat_, inputHasFormatting_, isCompleteNumber_, isExpectingCountryCallingCode_, shouldAddSpaceAfterNationalPrefix_;
+@property (nonatomic, strong, readwrite) NBPhoneNumberUtil *phoneUtil_;
+@property (nonatomic, assign, readwrite) NSUInteger lastMatchPosition_, originalPosition_, positionToRemember_;
+@property (nonatomic, assign, readwrite) NSUInteger MIN_LEADING_DIGITS_LENGTH_;
+@property (nonatomic, strong, readwrite) NSMutableArray *possibleFormats_;
+@property (nonatomic, strong, readwrite) NBPhoneMetaData *currentMetaData_, *defaultMetaData_, *EMPTY_METADATA_;
+
+@end
+
+
+@implementation NBAsYouTypeFormatter
+
+- (id)init
+{
+ self = [super init];
+
+ if (self) {
+ /**
+ * @type {i18n.phonenumbers.PhoneNumberUtil}
+ * @private
+ */
+ self.phoneUtil_ = [NBPhoneNumberUtil sharedInstance];
+
+ /**
+ * The digits that have not been entered yet will be represented by a \u2008,
+ * the punctuation space.
+ * @const
+ * @type {string}
+ * @private
+ */
+ self.DIGIT_PLACEHOLDER_ = @"\u2008";
+
+ /**
+ * Character used when appropriate to separate a prefix, such as a long NDD or a
+ * country calling code, from the national number.
+ * @const
+ * @type {string}
+ * @private
+ */
+ self.SEPARATOR_BEFORE_NATIONAL_NUMBER_ = @" ";
+
+ /**
+ * 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.
+ * @const
+ * @type {number}
+ * @private
+ */
+ self.MIN_LEADING_DIGITS_LENGTH_ = 3;
+
+ /**
+ * @type {string}
+ * @private
+ */
+ self.currentOutput_ = @"";
+
+ /**
+ * @type {!goog.string.StringBuffer}
+ * @private
+ */
+ self.formattingTemplate_ = [NSMutableString stringWithString:@""];
+
+ NSError *aError = nil;
+
+ /**
+ * @type {RegExp}
+ * @private
+ */
+ self.DIGIT_PATTERN_ = [NSRegularExpression regularExpressionWithPattern:self.DIGIT_PLACEHOLDER_ options:0 error:&aError];
+
+ /**
+ * A set of characters that, if found in a national prefix formatting rules, are
+ * an indicator to us that we should separate the national prefix from the
+ * number when formatting.
+ * @const
+ * @type {RegExp}
+ * @private
+ */
+ self.NATIONAL_PREFIX_SEPARATORS_PATTERN_ = [NSRegularExpression regularExpressionWithPattern:@"[- ]" options:0 error:&aError];
+
+ /**
+ * A pattern that is used to match character classes in regular expressions.
+ * An example of a character class is [1-4].
+ * @const
+ * @type {RegExp}
+ * @private
+ */
+ self.CHARACTER_CLASS_PATTERN_ = [NSRegularExpression regularExpressionWithPattern:@"\\[([^\\[\\]])*\\]" options:0 error:&aError];
+
+ /**
+ * Any digit in a regular expression that actually denotes a digit. For
+ * example, in the regular expression 80[0-2]\d{6,10}, the first 2 digits
+ * (8 and 0) are standalone digits, but the rest are not.
+ * Two look-aheads are needed because the number following \\d could be a
+ * two-digit number, since the phone number can be as long as 15 digits.
+ * @const
+ * @type {RegExp}
+ * @private
+ */
+ self.STANDALONE_DIGIT_PATTERN_ = [NSRegularExpression regularExpressionWithPattern:@"\\d(?=[^,}][^,}])" options:0 error:&aError];
+
+ /**
+ * 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.
+ * @const
+ * @type {RegExp}
+ * @private
+ */
+ NSString *eligible_format = @"^[-x‐-―−ー--/ ()()[].\\[\\]/~⁓∼~]*(\\$\\d[-x‐-―−ー--/ ()()[].\\[\\]/~⁓∼~]*)+$";
+ self.ELIGIBLE_FORMAT_PATTERN_ = [NSRegularExpression regularExpressionWithPattern:eligible_format options:0 error:&aError];
+
+ /**
+ * The pattern from numberFormat that is currently used to create
+ * formattingTemplate.
+ * @type {string}
+ * @private
+ */
+ self.currentFormattingPattern_ = @"";
+
+ /**
+ * @type {!goog.string.StringBuffer}
+ * @private
+ */
+ self.accruedInput_ = [NSMutableString stringWithString:@""];
+
+ /**
+ * @type {!goog.string.StringBuffer}
+ * @private
+ */
+ self.accruedInputWithoutFormatting_ = [NSMutableString stringWithString:@""];
+
+ /**
+ * This indicates whether AsYouTypeFormatter is currently doing the
+ * formatting.
+ * @type {BOOL}
+ * @private
+ */
+ self.ableToFormat_ = YES;
+
+ /**
+ * Set to YES when users enter their own formatting. AsYouTypeFormatter will
+ * do no formatting at all when this is set to YES.
+ * @type {BOOL}
+ * @private
+ */
+ self.inputHasFormatting_ = NO;
+
+ /**
+ * This is set to YES when we know the user is entering a full national
+ * significant number, since we have either detected a national prefix or an
+ * international dialing prefix. When this is YES, we will no longer use
+ * local number formatting patterns.
+ * @type {BOOL}
+ * @private
+ */
+ self.isCompleteNumber_ = NO;
+
+ /**
+ * @type {BOOL}
+ * @private
+ */
+ self.isExpectingCountryCallingCode_ = NO;
+
+ /**
+ * @type {number}
+ * @private
+ */
+ self.lastMatchPosition_ = 0;
+
+ /**
+ * The position of a digit upon which inputDigitAndRememberPosition is most
+ * recently invoked, as found in the original sequence of characters the user
+ * entered.
+ * @type {number}
+ * @private
+ */
+ self.originalPosition_ = 0;
+
+ /**
+ * The position of a digit upon which inputDigitAndRememberPosition is most
+ * recently invoked, as found in accruedInputWithoutFormatting.
+ * entered.
+ * @type {number}
+ * @private
+ */
+ self.positionToRemember_ = 0;
+
+ /**
+ * This contains anything that has been entered so far preceding the national
+ * significant number, and it is formatted (e.g. with space inserted). For
+ * example, this can contain IDD, country code, and/or NDD, etc.
+ * @type {!goog.string.StringBuffer}
+ * @private
+ */
+ self.prefixBeforeNationalNumber_ = [NSMutableString stringWithString:@""];
+
+ /**
+ * @type {BOOL}
+ * @private
+ */
+ self.shouldAddSpaceAfterNationalPrefix_ = NO;
+
+ /**
+ * This contains the national prefix that has been extracted. It contains only
+ * digits without formatting.
+ * @type {string}
+ * @private
+ */
+ self.nationalPrefixExtracted_ = @"";
+
+ /**
+ * @type {!goog.string.StringBuffer}
+ * @private
+ */
+ self.nationalNumber_ = [NSMutableString stringWithString:@""];
+
+ /**
+ * @type {Array.<i18n.phonenumbers.NumberFormat>}
+ * @private
+ */
+ self.possibleFormats_ = [[NSMutableArray alloc] init];
+ }
+
+ return self;
+}
+
+/**
+ * Constructs an AsYouTypeFormatter for the specific region.
+ *
+ * @param {string} regionCode the ISO 3166-1 two-letter region code that denotes
+ * the region where the phone number is being entered.
+ * @constructor
+ */
+
+- (id)initWithRegionCode:(NSString*)regionCode
+{
+ self = [self init];
+
+ if (self) {
+ /**
+ * @type {string}
+ * @private
+ */
+ self.defaultCountry_ = regionCode;
+ self.currentMetaData_ = [self getMetadataForRegion_:self.defaultCountry_];
+ /**
+ * @type {i18n.phonenumbers.PhoneMetadata}
+ * @private
+ */
+ self.defaultMetaData_ = self.currentMetaData_;
+
+ /**
+ * @const
+ * @type {i18n.phonenumbers.PhoneMetadata}
+ * @private
+ */
+ self.EMPTY_METADATA_ = [[NBPhoneMetaData alloc] init];
+ [self.EMPTY_METADATA_ setInternationalPrefix:@"NA"];
+ }
+
+ return self;
+}
+
+- (id)initWithRegionCodeForTest:(NSString*)regionCode
+{
+ self = [self init];
+
+ if (self) {
+ self.phoneUtil_ = [NBPhoneNumberUtil sharedInstanceForTest];
+
+ self.defaultCountry_ = regionCode;
+ self.currentMetaData_ = [self getMetadataForRegion_:self.defaultCountry_];
+ self.defaultMetaData_ = self.currentMetaData_;
+ self.EMPTY_METADATA_ = [[NBPhoneMetaData alloc] init];
+ [self.EMPTY_METADATA_ setInternationalPrefix:@"NA"];
+ }
+
+ return self;
+}
+
+/**
+ * The metadata needed by this class is the same for all regions sharing the
+ * same country calling code. Therefore, we return the metadata for "main"
+ * region for this country calling code.
+ * @param {string} regionCode an ISO 3166-1 two-letter region code.
+ * @return {i18n.phonenumbers.PhoneMetadata} main metadata for this region.
+ * @private
+ */
+- (NBPhoneMetaData*)getMetadataForRegion_:(NSString*)regionCode
+{
+
+ /** @type {number} */
+ NSNumber *countryCallingCode = [self.phoneUtil_ getCountryCodeForRegion:regionCode];
+ /** @type {string} */
+ NSString *mainCountry = [self.phoneUtil_ getRegionCodeForCountryCode:countryCallingCode];
+ /** @type {i18n.phonenumbers.PhoneMetadata} */
+ NBPhoneMetaData *metadata = [self.phoneUtil_ getMetadataForRegion:mainCountry];
+ if (metadata != nil) {
+ return metadata;
+ }
+ // 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 self.EMPTY_METADATA_;
+};
+
+
+/**
+ * @return {BOOL} YES if a new template is created as opposed to reusing the
+ * existing template.
+ * @private
+ */
+- (BOOL)maybeCreateNewTemplate_
+{
+ // When there are multiple available formats, the formatter uses the first
+ // format where a formatting template could be created.
+ /** @type {number} */
+ NSUInteger possibleFormatsLength = [self.possibleFormats_ count];
+ for (NSUInteger i = 0; i < possibleFormatsLength; ++i)
+ {
+ /** @type {i18n.phonenumbers.NumberFormat} */
+ NBNumberFormat *numberFormat = [self.possibleFormats_ safeObjectAtIndex:i];
+ /** @type {string} */
+ NSString *pattern = numberFormat.pattern;
+
+ if ([self.currentFormattingPattern_ isEqualToString:pattern]) {
+ return NO;
+ }
+
+ if ([self createFormattingTemplate_:numberFormat ])
+ {
+ self.currentFormattingPattern_ = pattern;
+ NSRange nationalPrefixRange = NSMakeRange(0, [numberFormat.nationalPrefixFormattingRule length]);
+ if (nationalPrefixRange.length > 0) {
+ NSTextCheckingResult *matchResult =
+ [self.NATIONAL_PREFIX_SEPARATORS_PATTERN_ firstMatchInString:numberFormat.nationalPrefixFormattingRule
+ options:0
+ range:nationalPrefixRange];
+ self.shouldAddSpaceAfterNationalPrefix_ = (matchResult != nil);
+ } else {
+ self.shouldAddSpaceAfterNationalPrefix_ = NO;
+ }
+ // With a new formatting template, the matched position using the old
+ // template needs to be reset.
+ self.lastMatchPosition_ = 0;
+ return YES;
+ }
+ }
+ self.ableToFormat_ = NO;
+ return NO;
+};
+
+
+/**
+ * @param {string} leadingThreeDigits first three digits of entered number.
+ * @private
+ */
+- (void)getAvailableFormats_:(NSString*)leadingThreeDigits
+{
+ /** @type {Array.<i18n.phonenumbers.NumberFormat>} */
+ BOOL isIntlNumberFormats = (self.isCompleteNumber_ && self.currentMetaData_.intlNumberFormats.count > 0);
+ NSMutableArray *formatList = isIntlNumberFormats ? self.currentMetaData_.intlNumberFormats : self.currentMetaData_.numberFormats;
+
+ /** @type {number} */
+ NSUInteger formatListLength = formatList.count;
+
+ for (NSUInteger i = 0; i < formatListLength; ++i)
+ {
+ /** @type {i18n.phonenumbers.NumberFormat} */
+ NBNumberFormat *format = [formatList safeObjectAtIndex:i];
+ /** @type {BOOL} */
+ BOOL nationalPrefixIsUsedByCountry = (self.currentMetaData_.nationalPrefix && self.currentMetaData_.nationalPrefix.length > 0);
+
+ if (!nationalPrefixIsUsedByCountry || self.isCompleteNumber_ || format.nationalPrefixOptionalWhenFormatting ||
+ [self.phoneUtil_ formattingRuleHasFirstGroupOnly:format.nationalPrefixFormattingRule])
+ {
+ if ([self isFormatEligible_:format.format]) {
+ [self.possibleFormats_ addObject:format];
+ }
+ }
+ }
+
+ [self narrowDownPossibleFormats_:leadingThreeDigits];
+};
+
+
+/**
+ * @param {string} format
+ * @return {BOOL}
+ * @private
+ */
+- (BOOL)isFormatEligible_:(NSString*)format
+{
+ NSTextCheckingResult *matchResult =
+ [self.ELIGIBLE_FORMAT_PATTERN_ firstMatchInString:format options:0 range:NSMakeRange(0, [format length])];
+ return (matchResult != nil);
+};
+
+
+/**
+ * @param {string} leadingDigits
+ * @private
+ */
+- (void)narrowDownPossibleFormats_:(NSString *)leadingDigits
+{
+ /** @type {Array.<i18n.phonenumbers.NumberFormat>} */
+ NSMutableArray *possibleFormats = [[NSMutableArray alloc] init];
+ /** @type {number} */
+ NSUInteger indexOfLeadingDigitsPattern = leadingDigits.length - self.MIN_LEADING_DIGITS_LENGTH_;
+ /** @type {number} */
+ NSUInteger possibleFormatsLength = self.possibleFormats_.count;
+ for (NSUInteger i = 0; i < possibleFormatsLength; ++i)
+ {
+ /** @type {i18n.phonenumbers.NumberFormat} */
+ NBNumberFormat *format = [self.possibleFormats_ safeObjectAtIndex:i];
+ if (format.leadingDigitsPatterns.count > indexOfLeadingDigitsPattern)
+ {
+ /** @type {string} */
+ NSString *leadingDigitsPattern = [format.leadingDigitsPatterns safeObjectAtIndex:indexOfLeadingDigitsPattern];
+
+ if ([self.phoneUtil_ stringPositionByRegex:leadingDigits regex:leadingDigitsPattern] == 0)
+ {
+ [possibleFormats addObject:format];
+ }
+ } else {
+ // else the particular format has no more specific leadingDigitsPattern,
+ // and it should be retained.
+ [possibleFormats addObject:[self.possibleFormats_ safeObjectAtIndex:i]];
+ }
+ }
+ self.possibleFormats_ = possibleFormats;
+};
+
+
+/**
+ * @param {i18n.phonenumbers.NumberFormat} format
+ * @return {BOOL}
+ * @private
+ */
+- (BOOL)createFormattingTemplate_:(NBNumberFormat*)format
+{
+ /** @type {string} */
+ NSString *numberPattern = format.pattern;
+
+ // The formatter doesn't format numbers when numberPattern contains '|', e.g.
+ // (20|3)\d{4}. In those cases we quickly return.
+ NSRange stringRange = [numberPattern rangeOfString:@"|"];
+ if (stringRange.location != NSNotFound) {
+ return NO;
+ }
+
+ // Replace anything in the form of [..] with \d
+ numberPattern = [self.CHARACTER_CLASS_PATTERN_ stringByReplacingMatchesInString:numberPattern
+ options:0 range:NSMakeRange(0, [numberPattern length])
+ withTemplate:@"\\\\d"];
+
+ // Replace any standalone digit (not the one in d{}) with \d
+ numberPattern = [self.STANDALONE_DIGIT_PATTERN_ stringByReplacingMatchesInString:numberPattern
+ options:0 range:NSMakeRange(0, [numberPattern length])
+ withTemplate:@"\\\\d"];
+ self.formattingTemplate_ = [NSMutableString stringWithString:@""];
+
+ /** @type {string} */
+ NSString *tempTemplate = [self getFormattingTemplate_:numberPattern numberFormat:format.format];
+ if (tempTemplate.length > 0) {
+ [self.formattingTemplate_ appendString:tempTemplate];
+ return YES;
+ }
+ return NO;
+};
+
+
+/**
+ * Gets a formatting template which can be used to efficiently format a
+ * partial number where digits are added one by one.
+ *
+ * @param {string} numberPattern
+ * @param {string} numberFormat
+ * @return {string}
+ * @private
+ */
+- (NSString*)getFormattingTemplate_:(NSString*)numberPattern numberFormat:(NSString*)numberFormat
+{
+ // Creates a phone number consisting only of the digit 9 that matches the
+ // numberPattern by applying the pattern to the longestPhoneNumber string.
+ /** @type {string} */
+ NSString *longestPhoneNumber = @"999999999999999";
+
+ /** @type {Array.<string>} */
+ NSArray *m = [self.phoneUtil_ matchedStringByRegex:longestPhoneNumber regex:numberPattern];
+
+ // this match will always succeed
+ /** @type {string} */
+ NSString *aPhoneNumber = [m safeObjectAtIndex:0];
+ // No formatting template can be created if the number of digits entered so
+ // far is longer than the maximum the current formatting rule can accommodate.
+ if (aPhoneNumber.length < self.nationalNumber_.length) {
+ return @"";
+ }
+ // Formats the number according to numberFormat
+ /** @type {string} */
+ NSString *template = [self.phoneUtil_ replaceStringByRegex:aPhoneNumber regex:numberPattern withTemplate:numberFormat];
+
+ // Replaces each digit with character DIGIT_PLACEHOLDER
+ template = [self.phoneUtil_ replaceStringByRegex:template regex:@"9" withTemplate:self.DIGIT_PLACEHOLDER_];
+ return template;
+};
+
+
+/**
+ * Clears the internal state of the formatter, so it can be reused.
+ */
+- (void)clear
+{
+ self.currentOutput_ = @"";
+ self.accruedInput_ = [NSMutableString stringWithString:@""];
+ self.accruedInputWithoutFormatting_ = [NSMutableString stringWithString:@""];
+ self.formattingTemplate_ = [NSMutableString stringWithString:@""];
+ self.lastMatchPosition_ = 0;
+ self.currentFormattingPattern_ = @"";
+ self.prefixBeforeNationalNumber_ = [NSMutableString stringWithString:@""];
+ self.nationalPrefixExtracted_ = @"";
+ self.nationalNumber_ = [NSMutableString stringWithString:@""];
+ self.ableToFormat_ = YES;
+ self.inputHasFormatting_ = NO;
+ self.positionToRemember_ = 0;
+ self.originalPosition_ = 0;
+ self.isCompleteNumber_ = NO;
+ self.isExpectingCountryCallingCode_ = NO;
+ [self.possibleFormats_ removeAllObjects];
+ self.shouldAddSpaceAfterNationalPrefix_ = NO;
+
+ if (self.currentMetaData_ != self.defaultMetaData_) {
+ self.currentMetaData_ = [self getMetadataForRegion_:self.defaultCountry_];
+ }
+}
+
+
+/**
+ * Formats a phone number on-the-fly as each digit is entered.
+ *
+ * @param {string} nextChar the most recently entered digit of a phone number.
+ * Formatting characters 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 {string} the partially formatted phone number.
+ */
+- (NSString*)inputDigit:(NSString*)nextChar
+{
+ self.currentOutput_ = [self inputDigitWithOptionToRememberPosition_:nextChar rememberPosition:NO];
+ return self.currentOutput_;
+}
+
+
+/**
+ * Same as {@link #inputDigit}, but remembers the position where
+ * {@code nextChar} is inserted, so 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}.
+ *
+ * @param {string} nextChar
+ * @return {string}
+ */
+- (NSString*)inputDigitAndRememberPosition:(NSString*)nextChar
+{
+ self.currentOutput_ = [self inputDigitWithOptionToRememberPosition_:nextChar rememberPosition:YES];
+ return self.currentOutput_;
+};
+
+
+/**
+ * @param {string} nextChar
+ * @param {BOOL} rememberPosition
+ * @return {string}
+ * @private
+ */
+- (NSString*)inputDigitWithOptionToRememberPosition_:(NSString*)nextChar rememberPosition:(BOOL)rememberPosition
+{
+ [self.accruedInput_ appendString:nextChar];
+
+ if (rememberPosition) {
+ self.originalPosition_ = self.accruedInput_.length;
+ }
+
+ // We do formatting on-the-fly only when each character entered is either a
+ // digit, or a plus sign (accepted at the start of the number only).
+ if (![self isDigitOrLeadingPlusSign_:nextChar])
+ {
+ self.ableToFormat_ = NO;
+ self.inputHasFormatting_ = YES;
+ } else {
+ nextChar = [self normalizeAndAccrueDigitsAndPlusSign_:nextChar rememberPosition:rememberPosition];
+ }
+
+ if (!self.ableToFormat_) {
+ // When we are unable to format because of reasons other than that
+ // formatting chars have been entered, it can be due to really long IDDs or
+ // NDDs. If that is the case, we might be able to do formatting again after
+ // extracting them.
+ if (self.inputHasFormatting_) {
+ return [NSString stringWithString:self.accruedInput_];
+ }
+ else if ([self attemptToExtractIdd_]) {
+ if ([self attemptToExtractCountryCallingCode_]) {
+ return [self attemptToChoosePatternWithPrefixExtracted_];
+ }
+ }
+ else if ([self ableToExtractLongerNdd_]) {
+ // Add an additional space to separate long NDD and national significant
+ // number for readability. We don't set shouldAddSpaceAfterNationalPrefix_
+ // to YES, since we don't want this to change later when we choose
+ // formatting templates.
+ [self.prefixBeforeNationalNumber_ appendString:[NSString stringWithFormat: @"%@", self.SEPARATOR_BEFORE_NATIONAL_NUMBER_]];
+ return [self attemptToChoosePatternWithPrefixExtracted_];
+ }
+ return self.accruedInput_;
+ }
+
+ // 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 (self.accruedInputWithoutFormatting_.length)
+ {
+ case 0:
+ case 1:
+ case 2:
+ return self.accruedInput_;
+ case 3:
+ if ([self attemptToExtractIdd_]) {
+ self.isExpectingCountryCallingCode_ = YES;
+ } else {
+ // No IDD or plus sign is found, might be entering in national format.
+ self.nationalPrefixExtracted_ = [self removeNationalPrefixFromNationalNumber_];
+ return [self attemptToChooseFormattingPattern_];
+ }
+ default:
+ if (self.isExpectingCountryCallingCode_) {
+ if ([self attemptToExtractCountryCallingCode_]) {
+ self.isExpectingCountryCallingCode_ = NO;
+ }
+ return [NSString stringWithFormat:@"%@%@", self.prefixBeforeNationalNumber_, self.nationalNumber_];
+ }
+
+ if (self.possibleFormats_.count > 0) {
+ // The formatting pattern is already chosen.
+ /** @type {string} */
+ NSString *tempNationalNumber = [self inputDigitHelper_:nextChar];
+ // See if the accrued digits can be formatted properly already. If not,
+ // use the results from inputDigitHelper, which does formatting based on
+ // the formatting pattern chosen.
+ /** @type {string} */
+ NSString *formattedNumber = [self attemptToFormatAccruedDigits_];
+ if (formattedNumber.length > 0) {
+ return formattedNumber;
+ }
+
+ [self narrowDownPossibleFormats_:self.nationalNumber_];
+
+ if ([self maybeCreateNewTemplate_]) {
+ return [self inputAccruedNationalNumber_];
+ }
+
+ return self.ableToFormat_ ? [self appendNationalNumber_:tempNationalNumber] : self.accruedInput_;
+ }
+ else {
+ return [self attemptToChooseFormattingPattern_];
+ }
+ }
+};
+
+
+/**
+ * @return {string}
+ * @private
+ */
+- (NSString*)attemptToChoosePatternWithPrefixExtracted_
+{
+ self.ableToFormat_ = YES;
+ self.isExpectingCountryCallingCode_ = NO;
+ [self.possibleFormats_ removeAllObjects];
+ return [self attemptToChooseFormattingPattern_];
+};
+
+
+/**
+ * Some national prefixes are a substring of others. If extracting the shorter
+ * NDD doesn't result in a number we can format, we try to see if we can extract
+ * a longer version here.
+ * @return {BOOL}
+ * @private
+ */
+- (BOOL)ableToExtractLongerNdd_
+{
+ if (self.nationalPrefixExtracted_.length > 0)
+ {
+ // Put the extracted NDD back to the national number before attempting to
+ // extract a new NDD.
+ /** @type {string} */
+ NSString *nationalNumberStr = [NSString stringWithString:self.nationalNumber_];
+ self.nationalNumber_ = [NSMutableString stringWithString:@""];
+ [self.nationalNumber_ appendString:self.nationalPrefixExtracted_];
+ [self.nationalNumber_ appendString:nationalNumberStr];
+ // Remove the previously extracted NDD from prefixBeforeNationalNumber. We
+ // cannot simply set it to empty string because people sometimes incorrectly
+ // enter national prefix after the country code, e.g. +44 (0)20-1234-5678.
+ /** @type {string} */
+ NSString *prefixBeforeNationalNumberStr = [NSString stringWithString:self.prefixBeforeNationalNumber_];
+ NSRange lastRange = [prefixBeforeNationalNumberStr rangeOfString:self.nationalPrefixExtracted_ options:NSBackwardsSearch];
+ /** @type {number} */
+ NSUInteger indexOfPreviousNdd = lastRange.location;
+ self.prefixBeforeNationalNumber_ = [NSMutableString stringWithString:@""];
+ [self.prefixBeforeNationalNumber_ appendString:[prefixBeforeNationalNumberStr substringWithRange:NSMakeRange(0, indexOfPreviousNdd)]];
+ }
+
+ return self.nationalPrefixExtracted_ != [self removeNationalPrefixFromNationalNumber_];
+};
+
+
+/**
+ * @param {string} nextChar
+ * @return {BOOL}
+ * @private
+ */
+- (BOOL)isDigitOrLeadingPlusSign_:(NSString*)nextChar
+{
+ NSString *digitPattern = [NSString stringWithFormat:@"([%@])", [self.phoneUtil_ VALID_DIGITS_STRING]];
+ NSString *plusPattern = [NSString stringWithFormat:@"[%@]+", [self.phoneUtil_ PLUS_CHARS_]];
+
+ BOOL isDigitPattern = [[self.phoneUtil_ matchesByRegex:nextChar regex:digitPattern] count] > 0;
+ BOOL isPlusPattern = [[self.phoneUtil_ matchesByRegex:nextChar regex:plusPattern] count] > 0;
+
+ return isDigitPattern || (self.accruedInput_.length == 1 && isPlusPattern);
+};
+
+
+/**
+ * Check to see if there is an exact pattern match for these digits. If so, we
+ * should use this instead of any other formatting template whose
+ * leadingDigitsPattern also matches the input.
+ * @return {string}
+ * @private
+ */
+- (NSString*)attemptToFormatAccruedDigits_
+{
+ /** @type {string} */
+ NSString *nationalNumber = [NSString stringWithString:self.nationalNumber_];
+
+ /** @type {number} */
+ NSUInteger possibleFormatsLength = self.possibleFormats_.count;
+ for (NSUInteger i = 0; i < possibleFormatsLength; ++i)
+ {
+ /** @type {i18n.phonenumbers.NumberFormat} */
+ NBNumberFormat *numberFormat = self.possibleFormats_[i];
+ /** @type {string} */
+ NSString * pattern = numberFormat.pattern;
+ /** @type {RegExp} */
+ NSString *patternRegExp = [NSString stringWithFormat:@"^(?:%@)$", pattern];
+ BOOL isPatternRegExp = [[self.phoneUtil_ matchesByRegex:nationalNumber regex:patternRegExp] count] > 0;
+ if (isPatternRegExp) {
+ if (numberFormat.nationalPrefixFormattingRule.length > 0) {
+ NSArray *matches = [self.NATIONAL_PREFIX_SEPARATORS_PATTERN_ matchesInString:numberFormat.nationalPrefixFormattingRule
+ options:0
+ range:NSMakeRange(0, numberFormat.nationalPrefixFormattingRule.length)];
+ self.shouldAddSpaceAfterNationalPrefix_ = [matches count] > 0;
+ } else {
+ self.shouldAddSpaceAfterNationalPrefix_ = NO;
+ }
+
+ /** @type {string} */
+ NSString *formattedNumber = [self.phoneUtil_ replaceStringByRegex:nationalNumber
+ regex:pattern
+ withTemplate:numberFormat.format];
+ return [self appendNationalNumber_:formattedNumber];
+ }
+ }
+ return @"";
+};
+
+
+/**
+ * Combines the national number with any prefix (IDD/+ and country code or
+ * national prefix) that was collected. A space will be inserted between them if
+ * the current formatting template indicates this to be suitable.
+ * @param {string} nationalNumber The number to be appended.
+ * @return {string} The combined number.
+ * @private
+ */
+- (NSString*)appendNationalNumber_:(NSString*)nationalNumber
+{
+ /** @type {number} */
+ NSUInteger prefixBeforeNationalNumberLength = self.prefixBeforeNationalNumber_.length;
+ unichar blank_char = [self.SEPARATOR_BEFORE_NATIONAL_NUMBER_ characterAtIndex:0];
+ if (self.shouldAddSpaceAfterNationalPrefix_ && prefixBeforeNationalNumberLength > 0 &&
+ [self.prefixBeforeNationalNumber_ characterAtIndex:prefixBeforeNationalNumberLength - 1] != blank_char)
+ {
+ // We want to add a space after the national prefix if the national prefix
+ // formatting rule indicates that this would normally be done, with the
+ // exception of the case where we already appended a space because the NDD
+ // was surprisingly long.
+
+ return [NSString stringWithFormat:@"%@%@%@", self.prefixBeforeNationalNumber_, self.SEPARATOR_BEFORE_NATIONAL_NUMBER_, nationalNumber];
+ } else {
+ return [NSString stringWithFormat:@"%@%@", self.prefixBeforeNationalNumber_, nationalNumber];
+ }
+};
+
+
+/**
+ * Returns the current position in the partially formatted phone number of the
+ * character which was previously passed in as the parameter of
+ * {@link #inputDigitAndRememberPosition}.
+ *
+ * @return {number}
+ */
+- (NSInteger)getRememberedPosition
+{
+ if (!self.ableToFormat_) {
+ return self.originalPosition_;
+ }
+ /** @type {number} */
+ NSUInteger accruedInputIndex = 0;
+ /** @type {number} */
+ NSUInteger currentOutputIndex = 0;
+ /** @type {string} */
+ NSString *accruedInputWithoutFormatting = self.accruedInputWithoutFormatting_;
+ /** @type {string} */
+ NSString *currentOutput = self.currentOutput_;
+
+ while (accruedInputIndex < self.positionToRemember_ && currentOutputIndex < currentOutput.length)
+ {
+ if ([accruedInputWithoutFormatting characterAtIndex:accruedInputIndex] == [currentOutput characterAtIndex:currentOutputIndex])
+ {
+ accruedInputIndex++;
+ }
+ currentOutputIndex++;
+ }
+ return currentOutputIndex;
+};
+
+
+/**
+ * Attempts to set the formatting template and returns a string which contains
+ * the formatted version of the digits entered so far.
+ *
+ * @return {string}
+ * @private
+ */
+- (NSString*)attemptToChooseFormattingPattern_
+{
+ /** @type {string} */
+ NSString *nationalNumber = [self.nationalNumber_ copy];
+ // We start to attempt to format only when as least MIN_LEADING_DIGITS_LENGTH
+ // digits of national number (excluding national prefix) have been entered.
+ if (nationalNumber.length >= self.MIN_LEADING_DIGITS_LENGTH_) {
+ [self getAvailableFormats_:[nationalNumber substringWithRange:NSMakeRange(0, self.MIN_LEADING_DIGITS_LENGTH_)]];
+ return [self maybeCreateNewTemplate_] ? [self inputAccruedNationalNumber_] : self.accruedInput_;
+ } else {
+ return [self appendNationalNumber_:nationalNumber];
+ }
+}
+
+
+/**
+ * Invokes inputDigitHelper on each digit of the national number accrued, and
+ * returns a formatted string in the end.
+ *
+ * @return {string}
+ * @private
+ */
+- (NSString*)inputAccruedNationalNumber_
+{
+ /** @type {string} */
+ NSString *nationalNumber = [self.nationalNumber_ copy];
+ /** @type {number} */
+ NSUInteger lengthOfNationalNumber = nationalNumber.length;
+ if (lengthOfNationalNumber > 0) {
+ /** @type {string} */
+ NSString *tempNationalNumber = @"";
+ for (NSUInteger i = 0; i < lengthOfNationalNumber; i++)
+ {
+ tempNationalNumber = [self inputDigitHelper_:[NSString stringWithFormat: @"%C", [nationalNumber characterAtIndex:i]]];
+ }
+ return self.ableToFormat_ ? [self appendNationalNumber_:tempNationalNumber] : self.accruedInput_;
+ } else {
+ return self.prefixBeforeNationalNumber_;
+ }
+};
+
+
+/**
+ * @return {BOOL} YES if the current country is a NANPA country and the
+ * national number begins with the national prefix.
+ * @private
+ */
+- (BOOL)isNanpaNumberWithNationalPrefix_
+{
+ // For NANPA numbers beginning with 1[2-9], treat the 1 as the national
+ // prefix. The reason is that national significant numbers in NANPA always
+ // start with [2-9] after the national prefix. Numbers beginning with 1[01]
+ // can only be short/emergency numbers, which don't need the national prefix.
+ if (![self.currentMetaData_.countryCode isEqualToNumber:@1]) {
+ return NO;
+ }
+
+ /** @type {string} */
+ NSString *nationalNumber = [self.nationalNumber_ copy];
+ return ([nationalNumber characterAtIndex:0] == '1') && ([nationalNumber characterAtIndex:1] != '0') &&
+ ([nationalNumber characterAtIndex:1] != '1');
+};
+
+
+/**
+ * Returns the national prefix extracted, or an empty string if it is not
+ * present.
+ * @return {string}
+ * @private
+ */
+- (NSString*)removeNationalPrefixFromNationalNumber_
+{
+ /** @type {string} */
+ NSString *nationalNumber = [self.nationalNumber_ copy];
+ /** @type {number} */
+ NSUInteger startOfNationalNumber = 0;
+
+ if ([self isNanpaNumberWithNationalPrefix_]) {
+ startOfNationalNumber = 1;
+ [self.prefixBeforeNationalNumber_ appendString:@"1"];
+ [self.prefixBeforeNationalNumber_ appendFormat:@"%@", self.SEPARATOR_BEFORE_NATIONAL_NUMBER_];
+ self.isCompleteNumber_ = YES;
+ }
+ else if (self.currentMetaData_.nationalPrefixForParsing != nil && self.currentMetaData_.nationalPrefixForParsing.length > 0)
+ {
+ /** @type {RegExp} */
+ NSString *nationalPrefixForParsing = [NSString stringWithFormat:@"^(?:%@)", self.currentMetaData_.nationalPrefixForParsing];
+ /** @type {Array.<string>} */
+ NSArray *m = [self.phoneUtil_ matchedStringByRegex:nationalNumber regex:nationalPrefixForParsing];
+ NSString *firstString = [m safeObjectAtIndex:0];
+ if (m != nil && firstString != nil && firstString.length > 0) {
+ // When the national prefix is detected, we use international formatting
+ // rules instead of national ones, because national formatting rules could
+ // contain local formatting rules for numbers entered without area code.
+ self.isCompleteNumber_ = YES;
+ startOfNationalNumber = firstString.length;
+ [self.prefixBeforeNationalNumber_ appendString:[nationalNumber substringWithRange:NSMakeRange(0, startOfNationalNumber)]];
+ }
+ }
+
+ self.nationalNumber_ = [NSMutableString stringWithString:@""];
+ [self.nationalNumber_ appendString:[nationalNumber substringFromIndex:startOfNationalNumber]];
+ return [nationalNumber substringWithRange:NSMakeRange(0, startOfNationalNumber)];
+};
+
+
+/**
+ * Extracts IDD and plus sign to prefixBeforeNationalNumber when they are
+ * available, and places the remaining input into nationalNumber.
+ *
+ * @return {BOOL} YES when accruedInputWithoutFormatting begins with the
+ * plus sign or valid IDD for defaultCountry.
+ * @private
+ */
+- (BOOL)attemptToExtractIdd_
+{
+ /** @type {string} */
+ NSString *accruedInputWithoutFormatting = [self.accruedInputWithoutFormatting_ copy];
+ /** @type {RegExp} */
+ NSString *internationalPrefix = [NSString stringWithFormat:@"^(?:\\+|%@)", self.currentMetaData_.internationalPrefix];
+ /** @type {Array.<string>} */
+ NSArray *m = [self.phoneUtil_ matchedStringByRegex:accruedInputWithoutFormatting regex:internationalPrefix];
+
+ NSString *firstString = [m safeObjectAtIndex:0];
+
+ if (m != nil && firstString != nil && firstString.length > 0) {
+ self.isCompleteNumber_ = YES;
+ /** @type {number} */
+ NSUInteger startOfCountryCallingCode = firstString.length;
+ self.nationalNumber_ = [NSMutableString stringWithString:@""];
+ [self.nationalNumber_ appendString:[accruedInputWithoutFormatting substringFromIndex:startOfCountryCallingCode]];
+ self.prefixBeforeNationalNumber_ = [NSMutableString stringWithString:@""];
+ [self.prefixBeforeNationalNumber_ appendString:[accruedInputWithoutFormatting substringWithRange:NSMakeRange(0, startOfCountryCallingCode)]];
+
+ if ([accruedInputWithoutFormatting characterAtIndex:0] != '+')
+ {
+ [self.prefixBeforeNationalNumber_ appendString:[NSString stringWithFormat: @"%@", self.SEPARATOR_BEFORE_NATIONAL_NUMBER_]];
+ }
+ return YES;
+ }
+ return NO;
+};
+
+
+/**
+ * Extracts the country calling code from the beginning of nationalNumber to
+ * prefixBeforeNationalNumber when they are available, and places the remaining
+ * input into nationalNumber.
+ *
+ * @return {BOOL} YES when a valid country calling code can be found.
+ * @private
+ */
+- (BOOL)attemptToExtractCountryCallingCode_
+{
+ if (self.nationalNumber_.length == 0) {
+ return NO;
+ }
+
+ /** @type {!goog.string.StringBuffer} */
+ NSString *numberWithoutCountryCallingCode = @"";
+
+ /** @type {number} */
+ NSNumber *countryCode = [self.phoneUtil_ extractCountryCode:self.nationalNumber_ nationalNumber:&numberWithoutCountryCallingCode];
+
+ if ([countryCode isEqualToNumber:@0]) {
+ return NO;
+ }
+
+ self.nationalNumber_ = [NSMutableString stringWithString:@""];
+ [self.nationalNumber_ appendString:numberWithoutCountryCallingCode];
+
+ /** @type {string} */
+ NSString *newRegionCode = [self.phoneUtil_ getRegionCodeForCountryCode:countryCode];
+
+ if ([[self.phoneUtil_ REGION_CODE_FOR_NON_GEO_ENTITY] isEqualToString:newRegionCode]) {
+ self.currentMetaData_ = [self.phoneUtil_ getMetadataForNonGeographicalRegion:countryCode];
+ } else if (newRegionCode != self.defaultCountry_)
+ {
+ self.currentMetaData_ = [self getMetadataForRegion_:newRegionCode];
+ }
+
+ /** @type {string} */
+ NSString *countryCodeString = [NSString stringWithFormat:@"%@", countryCode];
+ [self.prefixBeforeNationalNumber_ appendString:countryCodeString];
+ [self.prefixBeforeNationalNumber_ appendString:[NSString stringWithFormat: @"%@", self.SEPARATOR_BEFORE_NATIONAL_NUMBER_]];
+ return YES;
+};
+
+
+/**
+ * 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. This method assumes its input is either a digit or the
+ * plus sign.
+ *
+ * @param {string} nextChar
+ * @param {BOOL} rememberPosition
+ * @return {string}
+ * @private
+ */
+- (NSString*)normalizeAndAccrueDigitsAndPlusSign_:(NSString *)nextChar rememberPosition:(BOOL)rememberPosition
+{
+ /** @type {string} */
+ NSString *normalizedChar;
+
+ if ([nextChar isEqualToString:@"+"]) {
+ normalizedChar = nextChar;
+ [self.accruedInputWithoutFormatting_ appendString:nextChar];
+ } else {
+ normalizedChar = [[self.phoneUtil_ DIGIT_MAPPINGS] objectForKey:nextChar];
+ [self.accruedInputWithoutFormatting_ appendString:normalizedChar];
+ [self.nationalNumber_ appendString:normalizedChar];
+ }
+
+ if (rememberPosition) {
+ self.positionToRemember_ = self.accruedInputWithoutFormatting_.length;
+ }
+
+ return normalizedChar;
+};
+
+
+/**
+ * @param {string} nextChar
+ * @return {string}
+ * @private
+ */
+- (NSString*)inputDigitHelper_:(NSString *)nextChar
+{
+ /** @type {string} */
+ NSString *formattingTemplate = [self.formattingTemplate_ copy];
+ NSString *subedString = @"";
+
+ if (formattingTemplate.length > self.lastMatchPosition_) {
+ subedString = [formattingTemplate substringFromIndex:self.lastMatchPosition_];
+ }
+
+ if ([self.phoneUtil_ stringPositionByRegex:subedString regex:self.DIGIT_PLACEHOLDER_] >= 0) {
+ /** @type {number} */
+ NSUInteger digitPatternStart = [self.phoneUtil_ stringPositionByRegex:formattingTemplate regex:self.DIGIT_PLACEHOLDER_];
+
+ /** @type {string} */
+ NSRange tempRange = [formattingTemplate rangeOfString:self.DIGIT_PLACEHOLDER_];
+ NSString *tempTemplate = [formattingTemplate stringByReplacingOccurrencesOfString:self.DIGIT_PLACEHOLDER_
+ withString:nextChar
+ options:NSLiteralSearch
+ range:tempRange];
+ self.formattingTemplate_ = [NSMutableString stringWithString:@""];
+ [self.formattingTemplate_ appendString:tempTemplate];
+ self.lastMatchPosition_ = digitPatternStart;
+ return [tempTemplate substringWithRange:NSMakeRange(0, self.lastMatchPosition_ + 1)];
+ } else {
+ if (self.possibleFormats_.count == 1)
+ {
+ // More digits are entered than we could handle, and there are no other
+ // valid patterns to try.
+ self.ableToFormat_ = NO;
+ } // else, we just reset the formatting pattern.
+ self.currentFormattingPattern_ = @"";
+ return self.accruedInput_;
+ }
+};
+
+@end
diff --git a/libPhoneNumber/NBNumberFormat.h b/libPhoneNumber/NBNumberFormat.h
new file mode 100644
index 0000000..d2e8749
--- /dev/null
+++ b/libPhoneNumber/NBNumberFormat.h
@@ -0,0 +1,22 @@
+//
+// NBPhoneNumberFormat.h
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import <Foundation/Foundation.h>
+
+@interface NBNumberFormat : NSObject
+
+// from phonemetadata.pb.js
+/* 1 */ @property (nonatomic, strong, readwrite) NSString *pattern;
+/* 2 */ @property (nonatomic, strong, readwrite) NSString *format;
+/* 3 */ @property (nonatomic, strong, readwrite) NSMutableArray *leadingDigitsPatterns;
+/* 4 */ @property (nonatomic, strong, readwrite) NSString *nationalPrefixFormattingRule;
+/* 6 */ @property (nonatomic, assign, readwrite) BOOL nationalPrefixOptionalWhenFormatting;
+/* 5 */ @property (nonatomic, strong, readwrite) NSString *domesticCarrierCodeFormattingRule;
+
+- (id)initWithData:(id)data;
+
+@end
diff --git a/libPhoneNumber/NBNumberFormat.m b/libPhoneNumber/NBNumberFormat.m
new file mode 100644
index 0000000..5f261a7
--- /dev/null
+++ b/libPhoneNumber/NBNumberFormat.m
@@ -0,0 +1,139 @@
+//
+// NBPhoneNumberFormat.m
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import "NBNumberFormat.h"
+#import "NBPhoneNumberDefines.h"
+
+@implementation NBNumberFormat
+
+@synthesize pattern, format, leadingDigitsPatterns, nationalPrefixFormattingRule, nationalPrefixOptionalWhenFormatting, domesticCarrierCodeFormattingRule;
+
+
+- (id)initWithData:(id)data
+{
+ self = [self init];
+
+ if (self && data != nil && [data isKindOfClass:[NSArray class]])
+ {
+ /* 1 */ self.pattern = [data safeObjectAtIndex:1];
+ /* 2 */ self.format = [data safeObjectAtIndex:2];
+ /* 3 */ self.leadingDigitsPatterns = [self stringArrayFromData:[data safeObjectAtIndex:3]]; // NSString array
+ /* 4 */ self.nationalPrefixFormattingRule = [data safeObjectAtIndex:4];
+ /* 6 */ self.nationalPrefixOptionalWhenFormatting = [[data safeObjectAtIndex:6] boolValue];
+ /* 5 */ self.domesticCarrierCodeFormattingRule = [data safeObjectAtIndex:5];
+ }
+
+ return self;
+}
+
+
+- (id)init
+{
+ self = [super init];
+
+ if (self)
+ {
+ self.nationalPrefixOptionalWhenFormatting = NO;
+ self.leadingDigitsPatterns = [[NSMutableArray alloc] init];
+ }
+
+ return self;
+}
+
+
+- (NSMutableArray*)stringArrayFromData:(id)data
+{
+ NSMutableArray *resArray = [[NSMutableArray alloc] init];
+ if (data != nil && [data isKindOfClass:[NSArray class]])
+ {
+ for (id numFormat in data)
+ {
+ if ([numFormat isKindOfClass:[NSString class]])
+ {
+ [resArray addObject:numFormat];
+ }
+ else
+ {
+ [resArray addObject:[numFormat stringValue]];
+ }
+ }
+ }
+
+ return resArray;
+}
+
+
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@"[pattern:%@, format:%@, leadingDigitsPattern:%@, nationalPrefixFormattingRule:%@, nationalPrefixOptionalWhenFormatting:%@, domesticCarrierCodeFormattingRule:%@]",
+ self.pattern, self.format, self.leadingDigitsPatterns, self.nationalPrefixFormattingRule, self.nationalPrefixOptionalWhenFormatting?@"Y":@"N", self.domesticCarrierCodeFormattingRule];
+}
+
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ NBNumberFormat *phoneFormatCopy = [[NBNumberFormat allocWithZone:zone] init];
+
+ /*
+ 1 @property (nonatomic, strong, readwrite) NSString *pattern;
+ 2 @property (nonatomic, strong, readwrite) NSString *format;
+ 3 @property (nonatomic, strong, readwrite) NSString *leadingDigitsPattern;
+ 4 @property (nonatomic, strong, readwrite) NSString *nationalPrefixFormattingRule;
+ 6 @property (nonatomic, assign, readwrite) BOOL nationalPrefixOptionalWhenFormatting;
+ 5 @property (nonatomic, strong, readwrite) NSString *domesticCarrierCodeFormattingRule;
+ */
+
+ phoneFormatCopy.pattern = [self.pattern copy];
+ phoneFormatCopy.format = [self.format copy];
+ phoneFormatCopy.leadingDigitsPatterns = [self.leadingDigitsPatterns copy];
+ phoneFormatCopy.nationalPrefixFormattingRule = [self.nationalPrefixFormattingRule copy];
+ phoneFormatCopy.nationalPrefixOptionalWhenFormatting = self.nationalPrefixOptionalWhenFormatting;
+ phoneFormatCopy.domesticCarrierCodeFormattingRule = [self.domesticCarrierCodeFormattingRule copy];
+
+ return phoneFormatCopy;
+}
+
+
+- (id)initWithCoder:(NSCoder*)coder
+{
+ if (self = [super init])
+ {
+ self.pattern = [coder decodeObjectForKey:@"pattern"];
+ self.format = [coder decodeObjectForKey:@"format"];
+ self.leadingDigitsPatterns = [coder decodeObjectForKey:@"leadingDigitsPatterns"];
+ self.nationalPrefixFormattingRule = [coder decodeObjectForKey:@"nationalPrefixFormattingRule"];
+ self.nationalPrefixOptionalWhenFormatting = [[coder decodeObjectForKey:@"nationalPrefixOptionalWhenFormatting"] boolValue];
+ self.domesticCarrierCodeFormattingRule = [coder decodeObjectForKey:@"domesticCarrierCodeFormattingRule"];
+ }
+ return self;
+}
+
+
+- (void)encodeWithCoder:(NSCoder*)coder
+{
+ [coder encodeObject:self.pattern forKey:@"pattern"];
+ [coder encodeObject:self.format forKey:@"format"];
+ [coder encodeObject:self.leadingDigitsPatterns forKey:@"leadingDigitsPatterns"];
+ [coder encodeObject:self.nationalPrefixFormattingRule forKey:@"nationalPrefixFormattingRule"];
+ [coder encodeObject:[NSNumber numberWithBool:self.nationalPrefixOptionalWhenFormatting] forKey:@"nationalPrefixOptionalWhenFormatting"];
+ [coder encodeObject:self.domesticCarrierCodeFormattingRule forKey:@"domesticCarrierCodeFormattingRule"];
+}
+
+
+- (void)setData:(id)data
+{
+ if ([data isKindOfClass:[NSArray class]] || [data isKindOfClass:[NSMutableArray class]])
+ {
+
+ }
+ else if ([data isKindOfClass:[NSDictionary class]] || [data isKindOfClass:[NSMutableDictionary class]])
+ {
+
+ }
+}
+
+@end
diff --git a/libPhoneNumber/NBPhoneMetaData.h b/libPhoneNumber/NBPhoneMetaData.h
new file mode 100644
index 0000000..6767492
--- /dev/null
+++ b/libPhoneNumber/NBPhoneMetaData.h
@@ -0,0 +1,45 @@
+//
+// M2PhoneMetaData.h
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import <Foundation/Foundation.h>
+
+@class NBPhoneNumberDesc, NBNumberFormat;
+
+@interface NBPhoneMetaData : NSObject
+
+// from phonemetadata.pb.js
+/* 1 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *generalDesc;
+/* 2 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *fixedLine;
+/* 3 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *mobile;
+/* 4 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *tollFree;
+/* 5 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *premiumRate;
+/* 6 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *sharedCost;
+/* 7 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *personalNumber;
+/* 8 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *voip;
+/* 21 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *pager;
+/* 25 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *uan;
+/* 27 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *emergency;
+/* 28 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *voicemail;
+/* 24 */ @property (nonatomic, strong, readwrite) NBPhoneNumberDesc *noInternationalDialling;
+/* 9 */ @property (nonatomic, strong, readwrite) NSString *codeID;
+/* 10 */ @property (nonatomic, strong, readwrite) NSNumber *countryCode;
+/* 11 */ @property (nonatomic, strong, readwrite) NSString *internationalPrefix;
+/* 17 */ @property (nonatomic, strong, readwrite) NSString *preferredInternationalPrefix;
+/* 12 */ @property (nonatomic, strong, readwrite) NSString *nationalPrefix;
+/* 13 */ @property (nonatomic, strong, readwrite) NSString *preferredExtnPrefix;
+/* 15 */ @property (nonatomic, strong, readwrite) NSString *nationalPrefixForParsing;
+/* 16 */ @property (nonatomic, strong, readwrite) NSString *nationalPrefixTransformRule;
+/* 18 */ @property (nonatomic, assign, readwrite) BOOL sameMobileAndFixedLinePattern;
+/* 19 */ @property (nonatomic, strong, readwrite) NSMutableArray *numberFormats;
+/* 20 */ @property (nonatomic, strong, readwrite) NSMutableArray *intlNumberFormats;
+/* 22 */ @property (nonatomic, assign, readwrite) BOOL mainCountryForCode;
+/* 23 */ @property (nonatomic, strong, readwrite) NSString *leadingDigits;
+/* 26 */ @property (nonatomic, assign, readwrite) BOOL leadingZeroPossible;
+
+- (void)buildData:(id)data;
+
+@end
diff --git a/libPhoneNumber/NBPhoneMetaData.m b/libPhoneNumber/NBPhoneMetaData.m
new file mode 100644
index 0000000..8aa30d8
--- /dev/null
+++ b/libPhoneNumber/NBPhoneMetaData.m
@@ -0,0 +1,458 @@
+//
+// NBPhoneMetaData.m
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import "NBPhoneMetaData.h"
+#import "NBPhoneNumberDesc.h"
+#import "NBNumberFormat.h"
+#import "NBPhoneNumberDefines.h"
+
+@implementation NBPhoneMetaData
+
+@synthesize generalDesc, fixedLine, mobile, tollFree, premiumRate, sharedCost, personalNumber, voip, pager, uan, emergency, voicemail, noInternationalDialling;
+@synthesize codeID, countryCode;
+@synthesize internationalPrefix, preferredInternationalPrefix, nationalPrefix, preferredExtnPrefix, nationalPrefixForParsing, nationalPrefixTransformRule, sameMobileAndFixedLinePattern, numberFormats, intlNumberFormats, mainCountryForCode, leadingDigits, leadingZeroPossible;
+
+- (id)init
+{
+ self = [super init];
+
+ if (self)
+ {
+ [self setNumberFormats:[[NSMutableArray alloc] init]];
+ [self setIntlNumberFormats:[[NSMutableArray alloc] init]];
+
+ self.leadingZeroPossible = NO;
+ self.mainCountryForCode = NO;
+ }
+
+ return self;
+}
+
+
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@"* codeID[%@] countryCode[%@] generalDesc[%@] fixedLine[%@] mobile[%@] tollFree[%@] premiumRate[%@] sharedCost[%@] personalNumber[%@] voip[%@] pager[%@] uan[%@] emergency[%@] voicemail[%@] noInternationalDialling[%@] internationalPrefix[%@] preferredInternationalPrefix[%@] nationalPrefix[%@] preferredExtnPrefix[%@] nationalPrefixForParsing[%@] nationalPrefixTransformRule[%@] sameMobileAndFixedLinePattern[%@] numberFormats[%@] intlNumberFormats[%@] mainCountryForCode[%@] leadingDigits[%@] leadingZeroPossible[%@]",
+ self.codeID, self.countryCode, self.generalDesc, self.fixedLine, self.mobile, self.tollFree, self.premiumRate, self.sharedCost, self.personalNumber, self.voip, self.pager, self.uan, self.emergency, self.voicemail, self.noInternationalDialling, self.internationalPrefix, self.preferredInternationalPrefix, self.nationalPrefix, self.preferredExtnPrefix, self.nationalPrefixForParsing, self.nationalPrefixTransformRule, self.sameMobileAndFixedLinePattern?@"Y":@"N", self.numberFormats, self.intlNumberFormats, self.mainCountryForCode?@"Y":@"N", self.leadingDigits, self.leadingZeroPossible?@"Y":@"N"];
+}
+
+
+- (void)buildData:(id)data
+{
+ if (data != nil && [data isKindOfClass:[NSArray class]] )
+ {
+ /* 1 */ self.generalDesc = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:1]];
+ /* 2 */ self.fixedLine = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:2]];
+ /* 3 */ self.mobile = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:3]];
+ /* 4 */ self.tollFree = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:4]];
+ /* 5 */ self.premiumRate = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:5]];
+ /* 6 */ self.sharedCost = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:6]];
+ /* 7 */ self.personalNumber = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:7]];
+ /* 8 */ self.voip = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:8]];
+ /* 21 */ self.pager = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:21]];
+ /* 25 */ self.uan = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:25]];
+ /* 27 */ self.emergency = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:27]];
+ /* 28 */ self.voicemail = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:28]];
+ /* 24 */ self.noInternationalDialling = [[NBPhoneNumberDesc alloc] initWithData:[data safeObjectAtIndex:24]];
+ /* 9 */ self.codeID = [data safeObjectAtIndex:9];
+ /* 10 */ self.countryCode = [data safeObjectAtIndex:10];
+ /* 11 */ self.internationalPrefix = [data safeObjectAtIndex:11];
+ /* 17 */ self.preferredInternationalPrefix = [data safeObjectAtIndex:17];
+ /* 12 */ self.nationalPrefix = [data safeObjectAtIndex:12];
+ /* 13 */ self.preferredExtnPrefix = [data safeObjectAtIndex:13];
+ /* 15 */ self.nationalPrefixForParsing = [data safeObjectAtIndex:15];
+ /* 16 */ self.nationalPrefixTransformRule = [data safeObjectAtIndex:16];
+ /* 18 */ self.sameMobileAndFixedLinePattern = [[data safeObjectAtIndex:18] boolValue];
+ /* 19 */ self.numberFormats = [self numberFormatArrayFromData:[data safeObjectAtIndex:19]]; // NBNumberFormat array
+ /* 20 */ self.intlNumberFormats = [self numberFormatArrayFromData:[data safeObjectAtIndex:20]]; // NBNumberFormat array
+ /* 22 */ self.mainCountryForCode = [[data safeObjectAtIndex:22] boolValue];
+ /* 23 */ self.leadingDigits = [data safeObjectAtIndex:23];
+ /* 26 */ self.leadingZeroPossible = [[data safeObjectAtIndex:26] boolValue];
+ }
+ else
+ {
+ NSLog(@"nil data or wrong data type");
+ }
+}
+
+
+- (id)initWithCoder:(NSCoder*)coder
+{
+ if (self = [super init])
+ {
+ self.generalDesc = [coder decodeObjectForKey:@"generalDesc"];
+ self.fixedLine = [coder decodeObjectForKey:@"fixedLine"];
+ self.mobile = [coder decodeObjectForKey:@"mobile"];
+ self.tollFree = [coder decodeObjectForKey:@"tollFree"];
+ self.premiumRate = [coder decodeObjectForKey:@"premiumRate"];
+ self.sharedCost = [coder decodeObjectForKey:@"sharedCost"];
+ self.personalNumber = [coder decodeObjectForKey:@"personalNumber"];
+ self.voip = [coder decodeObjectForKey:@"voip"];
+ self.pager = [coder decodeObjectForKey:@"pager"];
+ self.uan = [coder decodeObjectForKey:@"uan"];
+ self.emergency = [coder decodeObjectForKey:@"emergency"];
+ self.voicemail = [coder decodeObjectForKey:@"voicemail"];
+ self.noInternationalDialling = [coder decodeObjectForKey:@"noInternationalDialling"];
+ self.codeID = [coder decodeObjectForKey:@"codeID"];
+ self.countryCode = [coder decodeObjectForKey:@"countryCode"];
+ self.internationalPrefix = [coder decodeObjectForKey:@"internationalPrefix"];
+ self.preferredInternationalPrefix = [coder decodeObjectForKey:@"preferredInternationalPrefix"];
+ self.nationalPrefix = [coder decodeObjectForKey:@"nationalPrefix"];
+ self.preferredExtnPrefix = [coder decodeObjectForKey:@"preferredExtnPrefix"];
+ self.nationalPrefixForParsing = [coder decodeObjectForKey:@"nationalPrefixForParsing"];
+ self.nationalPrefixTransformRule = [coder decodeObjectForKey:@"nationalPrefixTransformRule"];
+ self.sameMobileAndFixedLinePattern = [[coder decodeObjectForKey:@"sameMobileAndFixedLinePattern"] boolValue];
+ self.numberFormats = [coder decodeObjectForKey:@"numberFormats"];
+ self.intlNumberFormats = [coder decodeObjectForKey:@"intlNumberFormats"];
+ self.mainCountryForCode = [[coder decodeObjectForKey:@"mainCountryForCode"] boolValue];
+ self.leadingDigits = [coder decodeObjectForKey:@"leadingDigits"];
+ self.leadingZeroPossible = [[coder decodeObjectForKey:@"leadingZeroPossible"] boolValue];
+ }
+ return self;
+}
+
+
+- (void)encodeWithCoder:(NSCoder*)coder
+{
+ [coder encodeObject:self.generalDesc forKey:@"generalDesc"];
+ [coder encodeObject:self.fixedLine forKey:@"fixedLine"];
+ [coder encodeObject:self.mobile forKey:@"mobile"];
+ [coder encodeObject:self.tollFree forKey:@"tollFree"];
+ [coder encodeObject:self.premiumRate forKey:@"premiumRate"];
+ [coder encodeObject:self.sharedCost forKey:@"sharedCost"];
+ [coder encodeObject:self.personalNumber forKey:@"personalNumber"];
+ [coder encodeObject:self.voip forKey:@"voip"];
+ [coder encodeObject:self.pager forKey:@"pager"];
+ [coder encodeObject:self.uan forKey:@"uan"];
+ [coder encodeObject:self.emergency forKey:@"emergency"];
+ [coder encodeObject:self.voicemail forKey:@"voicemail"];
+ [coder encodeObject:self.noInternationalDialling forKey:@"noInternationalDialling"];
+ [coder encodeObject:self.codeID forKey:@"codeID"];
+ [coder encodeObject:self.countryCode forKey:@"countryCode"];
+ [coder encodeObject:self.internationalPrefix forKey:@"internationalPrefix"];
+ [coder encodeObject:self.preferredInternationalPrefix forKey:@"preferredInternationalPrefix"];
+ [coder encodeObject:self.nationalPrefix forKey:@"nationalPrefix"];
+ [coder encodeObject:self.preferredExtnPrefix forKey:@"preferredExtnPrefix"];
+ [coder encodeObject:self.nationalPrefixForParsing forKey:@"nationalPrefixForParsing"];
+ [coder encodeObject:self.nationalPrefixTransformRule forKey:@"nationalPrefixTransformRule"];
+ [coder encodeObject:[NSNumber numberWithBool:self.sameMobileAndFixedLinePattern] forKey:@"sameMobileAndFixedLinePattern"];
+ [coder encodeObject:self.numberFormats forKey:@"numberFormats"];
+ [coder encodeObject:self.intlNumberFormats forKey:@"intlNumberFormats"];
+ [coder encodeObject:[NSNumber numberWithBool:self.mainCountryForCode] forKey:@"mainCountryForCode"];
+ [coder encodeObject:self.leadingDigits forKey:@"leadingDigits"];
+ [coder encodeObject:[NSNumber numberWithBool:self.leadingZeroPossible] forKey:@"leadingZeroPossible"];
+}
+
+
+- (NSMutableArray*)numberFormatArrayFromData:(id)data
+{
+ NSMutableArray *resArray = [[NSMutableArray alloc] init];
+ if (data != nil && [data isKindOfClass:[NSArray class]])
+ {
+ for (id numFormat in data)
+ {
+ NBNumberFormat *newNumberFormat = [[NBNumberFormat alloc] initWithData:numFormat];
+ [resArray addObject:newNumberFormat];
+ }
+ }
+
+ return resArray;
+}
+
+/*
+- (NSString*)getNormalizedNationalPrefixFormattingRule
+{
+ NSString *replacedFormattingRule = [self.nationalPrefixFormattingRule stringByReplacingOccurrencesOfString:@"$NP" withString:self.nationalPrefix];
+ return replacedFormattingRule;
+}
+
+
+- (BOOL)sameMobileAndFixedLinePattern
+{
+ if ([self.mobile isEqual:self.fixedLine]) return YES;
+ return NO;
+}
+
+
+- (NBPhoneNumberDesc*)inheriteValues:(NBPhoneNumberDesc*)targetDesc
+{
+ if (targetDesc == nil)
+ {
+ targetDesc = [[NBPhoneNumberDesc alloc] init];
+ }
+
+ if (self.generalDesc != nil)
+ {
+ if (targetDesc.nationalNumberPattern == nil)
+ {
+ if (self.generalDesc.nationalNumberPattern != nil)
+ targetDesc.nationalNumberPattern = [self.generalDesc.nationalNumberPattern copy];
+ }
+
+ if (targetDesc.possibleNumberPattern == nil)
+ {
+ if (self.generalDesc.possibleNumberPattern != nil)
+ targetDesc.possibleNumberPattern = [self.generalDesc.possibleNumberPattern copy];
+ }
+
+ if (targetDesc.exampleNumber == nil)
+ {
+ if (self.generalDesc.exampleNumber != nil)
+ targetDesc.exampleNumber = [self.generalDesc.exampleNumber copy];
+ }
+ }
+
+ return targetDesc;
+}
+
+
+- (void)updateDescriptions
+{
+ self.fixedLine = [[self inheriteValues:self.fixedLine] copy];
+ self.mobile = [[self inheriteValues:self.mobile] copy];
+ self.tollFree = [[self inheriteValues:self.tollFree] copy];
+ self.premiumRate = [[self inheriteValues:self.premiumRate] copy];
+ self.sharedCost = [[self inheriteValues:self.sharedCost] copy];
+ self.personalNumber = [[self inheriteValues:self.personalNumber] copy];
+ self.voip = [[self inheriteValues:self.voip] copy];
+ self.pager = [[self inheriteValues:self.pager] copy];
+ self.uan = [[self inheriteValues:self.uan] copy];
+ self.emergency = [[self inheriteValues:self.emergency] copy];
+ self.voicemail = [[self inheriteValues:self.voicemail] copy];
+ self.noInternationalDialling = [[self inheriteValues:self.noInternationalDialling] copy];
+}
+
+
+- (void)setAttributes:(NSDictionary*)data
+{
+ NSString *attributeName = [data valueForKey:@"attributeName"];
+ id attributeContent = [data valueForKey:@"nodeContent"];
+
+ if ([attributeContent isKindOfClass:[NSString class]] && [attributeContent length] > 0)
+ attributeContent = [NBPhoneNumberManager stringByTrimming:attributeContent];
+
+ if (attributeName && [attributeName isKindOfClass:[NSString class]] && [attributeName length] > 0 && [attributeName isEqualToString:@"id"] &&
+ attributeContent && [attributeContent isKindOfClass:[NSString class]] && [attributeContent length] > 0)
+ {
+ [self setCodeID:attributeContent];
+ }
+ else if (attributeName && [attributeName isKindOfClass:[NSString class]] && [attributeName length] > 0 && attributeContent && [attributeContent isKindOfClass:[NSString class]] && [attributeContent length] > 0)
+ {
+ @try {
+ if ([[attributeContent lowercaseString] isEqualToString:@"true"])
+ {
+ [self setValue:[NSNumber numberWithBool:YES] forKey:attributeName];
+ }
+ else if ([[attributeContent lowercaseString] isEqualToString:@"false"])
+ {
+ [self setValue:[NSNumber numberWithBool:NO] forKey:attributeName];
+ }
+ else
+ {
+ [self setValue:attributeContent forKey:attributeName];
+ }
+ }
+ @catch (NSException *ex) {
+ NSLog(@"setAttributes setValue:%@ forKey:%@ error [%@]", attributeContent, attributeName, [attributeContent class]);
+ }
+ }
+}
+
+
+- (BOOL)setChilds:(id)data
+{
+ if (data && [data isKindOfClass:[NSDictionary class]])
+ {
+ NSString *nodeName = [data valueForKey:@"nodeName"];
+ id nodeContent = [data valueForKey:@"nodeContent"];
+
+ if ([nodeContent isKindOfClass:[NSString class]] && [nodeContent length] > 0)
+ nodeContent = [NBPhoneNumberManager stringByTrimming:nodeContent];
+
+ // [TYPE] PhoneNumberDesc
+ if ([nodeName isEqualToString:@"generalDesc"] || [nodeName isEqualToString:@"fixedLine"] || [nodeName isEqualToString:@"mobile"] || [nodeName isEqualToString:@"shortCode"] || [nodeName isEqualToString:@"emergency"] || [nodeName isEqualToString:@"voip"] || [nodeName isEqualToString:@"voicemail"] || [nodeName isEqualToString:@"uan"] || [nodeName isEqualToString:@"premiumRate"] || [nodeName isEqualToString:@"nationalNumberPattern"] || [nodeName isEqualToString:@"sharedCost"] || [nodeName isEqualToString:@"tollFree"] || [nodeName isEqualToString:@"noInternationalDialling"] || [nodeName isEqualToString:@"personalNumber"] || [nodeName isEqualToString:@"pager"] || [nodeName isEqualToString:@"areaCodeOptional"])
+ {
+ [self setNumberDescData:data];
+ return YES;
+ }
+ else if ([nodeName isEqualToString:@"availableFormats"])
+ {
+ [self setNumberFormatsData:data];
+ return YES;
+ }
+ else if ([nodeName isEqualToString:@"comment"] == NO && [nodeContent isKindOfClass:[NSString class]])
+ {
+ [self setValue:nodeContent forKey:nodeName];
+ return YES;
+ }
+ else if ([nodeName isEqualToString:@"comment"])
+ {
+ return YES;
+ }
+ }
+
+ return NO;
+}
+
+
+- (void)setNumberFormatsData:(id)data
+{
+ NSArray *nodeChildArray = [data valueForKey:@"nodeChildArray"];
+
+ for (id childNumberFormat in nodeChildArray)
+ {
+ NSArray *nodeChildAttributeNumberFormatArray = [childNumberFormat valueForKey:@"nodeAttributeArray"];
+ NSArray *nodeChildNodeNumberFormatArray = [childNumberFormat valueForKey:@"nodeChildArray"];
+
+ NSString *nodeName = [childNumberFormat valueForKey:@"nodeName"];
+
+ if ([nodeName isEqualToString:@"numberFormat"])
+ {
+ NBNumberFormat *newNumberFormat = [[NBNumberFormat alloc] init];
+
+ for (id childAttribute in nodeChildAttributeNumberFormatArray)
+ {
+ NSString *childNodeName = [childAttribute valueForKey:@"attributeName"];
+ NSString *childNodeContent = nil;
+
+ if ([childNodeName isEqualToString:@"comment"])
+ {
+ continue;
+ }
+
+ childNodeContent = [NBPhoneNumberManager stringByTrimming:[childAttribute valueForKey:@"nodeContent"]];
+
+ @try {
+ [newNumberFormat setValue:childNodeContent forKey:childNodeName];
+ }
+ @catch (NSException *ex) {
+ NSLog(@"nodeChildAttributeArray setValue:%@ forKey:%@ error [%@] %@", childNodeContent, childNodeName, [childNodeContent class], childAttribute);
+ }
+ }
+
+ for (id childNode in nodeChildNodeNumberFormatArray)
+ {
+ NSString *childNodeName = [childNode valueForKey:@"nodeName"];
+ NSString *childNodeContent = nil;
+
+ if ([childNodeName isEqualToString:@"comment"])
+ {
+ continue;
+ }
+
+ childNodeContent = [NBPhoneNumberManager stringByTrimming:[childNode valueForKey:@"nodeContent"]];
+
+ @try {
+ if ([childNodeName isEqualToString:@"leadingDigits"])
+ {
+ [newNumberFormat.leadingDigitsPattern addObject:childNodeContent];
+ }
+ else
+ {
+ if ([[childNodeContent lowercaseString] isEqualToString:@"true"])
+ {
+ [newNumberFormat setValue:[NSNumber numberWithBool:YES] forKey:childNodeName];
+ }
+ else if ([[childNodeContent lowercaseString] isEqualToString:@"false"])
+ {
+ [newNumberFormat setValue:[NSNumber numberWithBool:NO] forKey:childNodeName];
+ }
+ else
+ {
+ [newNumberFormat setValue:childNodeContent forKey:childNodeName];
+ }
+ }
+ }
+ @catch (NSException *ex) {
+ NSLog(@"nodeChildArray setValue:%@ forKey:%@ error [%@] %@", childNodeContent, childNodeName, [childNodeContent class], childNode);
+ }
+ }
+ [self.numberFormats addObject:newNumberFormat];
+ }
+ else if ([nodeName isEqualToString:@"comment"] == NO)
+ {
+ NSLog(@"process ========== %@", childNumberFormat);
+ }
+ }
+}
+
+
+- (void)setNumberDescData:(id)data
+{
+ NSString *nodeName = [data valueForKey:@"nodeName"];
+ NSArray *nodeChildArray = [data valueForKey:@"nodeChildArray"];
+
+ NBPhoneNumberDesc *newNumberDesc = [[NBPhoneNumberDesc alloc] init];
+
+ for (id childNode in nodeChildArray)
+ {
+ NSString *childNodeName = [childNode valueForKey:@"nodeName"];
+ NSString *childNodeContent = [NBPhoneNumberManager stringByTrimming:[childNode valueForKey:@"nodeContent"]];
+
+ if ([childNodeName isEqualToString:@"comment"])
+ {
+ continue;
+ }
+
+ @try {
+ if (childNodeContent && childNodeContent.length > 0)
+ {
+ [newNumberDesc setValue:childNodeContent forKey:childNodeName];
+ }
+ }
+ @catch (NSException *ex) {
+ NSLog(@"setNumberDesc setValue:%@ forKey:%@ error [%@]", childNodeContent, childNodeName, [childNodeContent class]);
+ }
+ }
+
+ nodeName = [nodeName lowercaseString];
+
+ if ([nodeName isEqualToString:[@"generalDesc" lowercaseString]])
+ self.generalDesc = newNumberDesc;
+
+ if ([nodeName isEqualToString:[@"fixedLine" lowercaseString]])
+ self.fixedLine = newNumberDesc;
+
+ if ([nodeName isEqualToString:[@"mobile" lowercaseString]])
+ self.mobile = newNumberDesc;
+
+ if ([nodeName isEqualToString:[@"tollFree" lowercaseString]]) {
+ [self setTollFree:newNumberDesc];
+ }
+
+ if ([nodeName isEqualToString:[@"premiumRate" lowercaseString]])
+ self.premiumRate = newNumberDesc;
+
+ if ([nodeName isEqualToString:[@"sharedCost" lowercaseString]]) {
+ self.sharedCost = newNumberDesc;
+ }
+
+ if ([nodeName isEqualToString:[@"personalNumber" lowercaseString]])
+ self.personalNumber = newNumberDesc;
+
+ if ([nodeName isEqualToString:[@"voip" lowercaseString]])
+ self.voip = newNumberDesc;
+
+ if ([nodeName isEqualToString:[@"pager" lowercaseString]])
+ self.pager = newNumberDesc;
+
+ if ([nodeName isEqualToString:[@"uan" lowercaseString]])
+ self.uan = newNumberDesc;
+
+ if ([nodeName isEqualToString:[@"emergency" lowercaseString]])
+ self.emergency = newNumberDesc;
+
+ if ([nodeName isEqualToString:[@"voicemail" lowercaseString]])
+ self.voicemail = newNumberDesc;
+
+ if ([nodeName isEqualToString:[@"noInternationalDialling" lowercaseString]])
+ self.noInternationalDialling = newNumberDesc;
+
+ [self updateDescriptions];
+}
+*/
+
+@end
\ No newline at end of file
diff --git a/libPhoneNumber/NBPhoneMetaDataGenerator.h b/libPhoneNumber/NBPhoneMetaDataGenerator.h
new file mode 100644
index 0000000..e729954
--- /dev/null
+++ b/libPhoneNumber/NBPhoneMetaDataGenerator.h
@@ -0,0 +1,14 @@
+//
+// NBPhoneMetaDataGenerator.h
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import <Foundation/Foundation.h>
+
+@interface NBPhoneMetaDataGenerator : NSObject
+
+- (void)generateMetadataClasses;
+
+@end
diff --git a/libPhoneNumber/NBPhoneMetaDataGenerator.m b/libPhoneNumber/NBPhoneMetaDataGenerator.m
new file mode 100644
index 0000000..1d59310
--- /dev/null
+++ b/libPhoneNumber/NBPhoneMetaDataGenerator.m
@@ -0,0 +1,361 @@
+//
+// NBPhoneMetaDataGenerator.m
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import "NBPhoneMetaDataGenerator.h"
+#import "NBPhoneMetaData.h"
+
+#define INDENT_TAB @" "
+NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+@implementation NBPhoneMetaDataGenerator
+
+
+- (id)init
+{
+ self = [super init];
+
+ if (self)
+ {
+ }
+
+ return self;
+}
+
+
+- (void)generateMetadataClasses
+{
+ NSDictionary *realMetadata = nil, *testMetadata = nil;
+ realMetadata = [self generateMetaData];
+ testMetadata = [self generateMetaDataWithTest];
+
+ @try
+ {
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+ NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"src"];
+
+ if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
+ {
+
+ NSError* error;
+ if( [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error])
+ {
+ }
+ else
+ {
+ NSLog(@"[%@] ERROR: attempting to write create MyFolder directory", [self class]);
+ }
+ }
+
+ NSDictionary *mappedRealData = [self mappingObject:realMetadata];
+ NSDictionary *mappedTestData = [self mappingObject:testMetadata];
+
+ [self createClassWithDictionary:mappedRealData name:@"NBPhoneNumberMetadata"];
+ [self createClassWithDictionary:mappedTestData name:@"NBPhoneNumberMetadataForTesting"];
+ }
+ @catch (NSException *exception)
+ {
+ NSLog(@"Error for creating metadata classes : %@", exception.reason);
+ }
+}
+
+
+- (void)createClassWithDictionary:(NSDictionary*)data name:(NSString*)name
+{
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+ NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"src"];
+
+ NSString *filePathData = [NSString stringWithFormat:@"%@/%@.plist", dataPath, name];
+ NSData *objData = [NSKeyedArchiver archivedDataWithRootObject:data];
+ [objData writeToFile:filePathData atomically:YES];
+
+ /*
+ NSString *codeStringHeader = [self generateSourceCodeWith:data name:name type:0];
+ NSString *codeStringSource = [self generateSourceCodeWith:data name:name type:1];
+
+ NSData *dataToWrite = [codeStringHeader dataUsingEncoding:NSUTF8StringEncoding];
+ [fileManager createFileAtPath:filePathHeader contents:dataToWrite attributes:nil];
+
+ dataToWrite = [codeStringSource dataUsingEncoding:NSUTF8StringEncoding];
+ [fileManager createFileAtPath:filePathSource contents:dataToWrite attributes:nil];
+ */
+
+ NSData *fileData = [NSData dataWithContentsOfFile:filePathData];
+ NSDictionary *unarchiveData = [NSKeyedUnarchiver unarchiveObjectWithData:fileData];
+
+ NSLog(@"Created file to...[%@ / %zu]", filePathData, (unsigned long)[unarchiveData count]);
+}
+
+
+- (NSDictionary*)mappingObject:(NSDictionary*)parsedJSONData
+{
+ NSMutableDictionary *resMedata = [[NSMutableDictionary alloc] init];
+ NSDictionary *countryCodeToRegionCodeMap = [parsedJSONData objectForKey:@"countryCodeToRegionCodeMap"];
+ NSDictionary *countryToMetadata = [parsedJSONData objectForKey:@"countryToMetadata"];
+ NSLog(@"- countryCodeToRegionCodeMap count [%zu]", (unsigned long)[countryCodeToRegionCodeMap count]);
+ NSLog(@"- countryToMetadata count [%zu]", (unsigned long)[countryToMetadata count]);
+
+ NSMutableDictionary *genetatedMetaData = [[NSMutableDictionary alloc] init];
+
+ for (id key in [countryToMetadata allKeys])
+ {
+ id metaData = [countryToMetadata objectForKey:key];
+
+ NBPhoneMetaData *newMetaData = [[NBPhoneMetaData alloc] init];
+ [newMetaData buildData:metaData];
+
+ [genetatedMetaData setObject:newMetaData forKey:key];
+ }
+
+ [resMedata setObject:countryCodeToRegionCodeMap forKey:@"countryCodeToRegionCodeMap"];
+ [resMedata setObject:genetatedMetaData forKey:@"countryToMetadata"];
+
+ return resMedata;
+}
+
+
+- (NSString *)genRandStringLength:(int)len
+{
+ NSMutableString *randomString = [NSMutableString stringWithCapacity: len];
+
+ for (int i=0; i<len; i++) {
+ [randomString appendFormat: @"%C", [letters characterAtIndex: arc4random() % [letters length]]];
+ }
+
+ return randomString;
+}
+
+
+- (NSString*)indentTab:(int)depth
+{
+ NSMutableString *resTab = [[NSMutableString alloc] initWithString:@""];
+ for (int i=0; i<depth; i++)
+ {
+ [resTab appendString:INDENT_TAB];
+ }
+ return resTab;
+}
+
+
+- (NSString *)documentsDirectory
+{
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ return [paths objectAtIndex:0];
+}
+
+
+- (NSDictionary *)generateMetaData
+{
+ NSString *filePath = [[NSBundle mainBundle] pathForResource:@"PhoneNumberMetaData" ofType:@"json"];
+ return [self parseJSON:filePath];
+}
+
+
+- (NSDictionary *)generateMetaDataWithTest
+{
+ NSString *filePath = [[NSBundle mainBundle] pathForResource:@"PhoneNumberMetaDataForTesting" ofType:@"json"];
+ return [self parseJSON:filePath];
+}
+
+
+- (NSDictionary *)parseJSON:(NSString*)filePath
+{
+ NSDictionary *jsonRes = nil;
+
+ @try {
+ NSData *jsonData = [NSData dataWithContentsOfFile:filePath];
+ NSError *error = nil;
+ jsonRes = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];
+ }
+ @catch (NSException *exception) {
+ NSLog(@"Error : %@", exception.reason);
+ }
+
+ return jsonRes;
+}
+
+
+/*
+- (NSString *)generateSourceCodeWith:(NSDictionary*)data name:(NSString*)name type:(int)type
+{
+ NSString *srcCode = @"";
+
+ if (type == 0)
+ {
+ NSString *curDir = [[NSFileManager defaultManager] currentDirectoryPath];
+ NSString *filePath = [NSString stringWithFormat:@"%@/%@", curDir, @"resources/PhoneNumberTemplateClass.h"];
+ NSString *stringContent = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
+
+ // header code
+ srcCode = [NSString stringWithFormat:stringContent, name, name];
+ }
+ else if (type == 1)
+ {
+ NSMutableString *srcImplement = [[NSMutableString alloc] initWithString:@""];
+
+ NSString *curDir = [[NSFileManager defaultManager] currentDirectoryPath];
+ NSString *filePath = [NSString stringWithFormat:@"%@/%@", curDir, @"resources/PhoneNumberTemplateClass.m"];
+ NSString *stringContent = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
+
+ // source code
+ NSString *instanceName = @"";
+ [srcImplement appendString:[self encodeNSDictionary:data indent:0 createdInstanceName:&instanceName]];
+
+ srcCode = [NSString stringWithFormat:stringContent, name, name, name, srcImplement, instanceName];
+ }
+
+ return srcCode;
+}
+
+
+- (NSString*)encodeNSDictionary:(NSDictionary*)object indent:(int)depth createdInstanceName:(NSString**)instanceName
+{
+ NSMutableString *curImplement = [[NSMutableString alloc] initWithString:@""];
+ NSEnumerator *enumerator = [object keyEnumerator];
+ id curKey = nil;
+
+ NSString *tempInstanceName = [NSString stringWithFormat:@"%@_%@_%d", [self genRandStringLength:16], @"NSDictionary", depth];
+
+ if (instanceName != NULL && (*instanceName) != nil)
+ (*instanceName) = [tempInstanceName copy];
+
+ NSString *createInstancFromat = @"%@NSMutableDictionary *%@ = [[NSMutableDictionary alloc] init];\n";
+
+ NSString *currentSyntaxFormat = nil;
+ NSString *buildedSyntax = nil;
+
+ [curImplement appendFormat:createInstancFromat, [self indentTab:depth], tempInstanceName];
+
+ while ((curKey = [enumerator nextObject]))
+ {
+ id curObject = [object objectForKey:curKey];
+ currentSyntaxFormat = @"%@[%@ setObject:%@ forKey:@\"%@\"];\n";
+
+ if ([curObject isKindOfClass:[NSString class]])
+ {
+ [curImplement appendFormat:currentSyntaxFormat, [self indentTab:depth], tempInstanceName, [self encodeNSString:curObject], curKey];
+ }
+ else if ([curObject isKindOfClass:[NSArray class]])
+ {
+ [curImplement appendFormat:@"%@{\n", [self indentTab:depth]];
+ NSString *tempArrayInstanceName = @"";
+ buildedSyntax = [self encodeNSArray:curObject indent:depth+1 createdInstanceName:&tempArrayInstanceName];
+ [curImplement appendString:buildedSyntax];
+ [curImplement appendString:[NSString stringWithFormat:currentSyntaxFormat, [self indentTab:depth + 1], tempInstanceName, tempArrayInstanceName, curKey]];
+ [curImplement appendFormat:@"%@}\n", [self indentTab:depth]];
+ }
+ else if ([curObject isKindOfClass:[NSDictionary class]])
+ {
+ [curImplement appendFormat:@"%@{\n", [self indentTab:depth]];
+ NSString *tempDictionaryInstanceName = @"";
+ buildedSyntax = [self encodeNSDictionary:curObject indent:depth+1 createdInstanceName:&tempDictionaryInstanceName];
+ [curImplement appendString:buildedSyntax];
+ [curImplement appendString:[NSString stringWithFormat:currentSyntaxFormat, [self indentTab:depth + 1], tempInstanceName, tempDictionaryInstanceName, curKey]];
+ [curImplement appendFormat:@"%@}\n", [self indentTab:depth]];
+ }
+ else if ([curObject isKindOfClass:[NSNumber class]])
+ {
+ [curImplement appendFormat:currentSyntaxFormat, [self indentTab:depth], tempInstanceName, [self encodeNSNumber:curObject], curKey];
+ }
+ else if ([curObject isKindOfClass:[NSNull class]])
+ {
+ [curImplement appendFormat:currentSyntaxFormat, [self indentTab:depth], tempInstanceName, [self encodeNSNull:curObject], curKey];
+ }
+ else
+ {
+ NSString *warningString = [NSString stringWithFormat:@"#warning cant parse data %@ key %@", curObject, curKey];
+ [curImplement appendString:warningString];
+ NSLog(@"!!! ERROR !!! - %@", warningString);
+ }
+ }
+
+ return curImplement;
+}
+
+
+- (NSString*)encodeNSArray:(NSArray*)object indent:(int)depth createdInstanceName:(NSString**)instanceName
+{
+ NSMutableString *curImplement = [[NSMutableString alloc] initWithString:@""];
+ NSString *tempInstanceName = [NSString stringWithFormat:@"%@_%@_%d", [self genRandStringLength:16], @"NSArray", depth];
+
+ if (instanceName != NULL && (*instanceName) != nil)
+ (*instanceName) = [tempInstanceName copy];
+
+ NSString *createInstancFromat = @"%@NSMutableArray *%@ = [[NSMutableArray alloc] init];\n";
+
+ NSString *currentSyntaxFormat = nil;
+ NSString *buildedSyntax = nil;
+
+ [curImplement appendFormat:createInstancFromat, [self indentTab:depth], tempInstanceName];
+
+ for (id data in object)
+ {
+ currentSyntaxFormat = @"%@[%@ addObject:%@];\n";
+
+ if ([data isKindOfClass:[NSString class]])
+ {
+ [curImplement appendFormat:currentSyntaxFormat, [self indentTab:depth], tempInstanceName, [self encodeNSString:data]];
+ }
+ else if ([data isKindOfClass:[NSNumber class]])
+ {
+ [curImplement appendFormat:currentSyntaxFormat, [self indentTab:depth], tempInstanceName, [self encodeNSNumber:data]];
+ }
+ else if ([data isKindOfClass:[NSArray class]])
+ {
+ [curImplement appendFormat:@"%@{\n", [self indentTab:depth]];
+ NSString *tempArrayInstanceName = @"";
+ buildedSyntax = [self encodeNSArray:data indent:depth+1 createdInstanceName:&tempArrayInstanceName];
+ [curImplement appendString:buildedSyntax];
+ [curImplement appendString:[NSString stringWithFormat:currentSyntaxFormat, [self indentTab:depth + 1], tempInstanceName, tempArrayInstanceName]];
+ [curImplement appendFormat:@"%@}\n", [self indentTab:depth]];
+ }
+ else if ([data isKindOfClass:[NSDictionary class]])
+ {
+ [curImplement appendFormat:@"%@{\n", [self indentTab:depth]];
+ NSString *tempDictionaryInstanceName = @"";
+ buildedSyntax = [self encodeNSDictionary:data indent:depth+1 createdInstanceName:&tempDictionaryInstanceName];
+ [curImplement appendString:buildedSyntax];
+ [curImplement appendString:[NSString stringWithFormat:currentSyntaxFormat, [self indentTab:depth + 1], tempInstanceName, tempDictionaryInstanceName]];
+ [curImplement appendFormat:@"%@}\n", [self indentTab:depth]];
+ }
+ else if ([data isKindOfClass:[NSNull class]])
+ {
+ [curImplement appendFormat:currentSyntaxFormat, [self indentTab:depth], tempInstanceName, [self encodeNSNull:data]];
+ }
+ else
+ {
+ NSString *warningString = [NSString stringWithFormat:@"#warning cant parse data %@ class %@", data, [data class]];
+ [curImplement appendString:warningString];
+ NSLog(@"!!! ERROR !!! - %@", warningString);
+ }
+
+ }
+ return curImplement;
+}
+
+
+- (NSString*)encodeNSNull:(NSNull*)object
+{
+ return [NSString stringWithFormat:@"%@", @"[NSNull null]"];
+}
+
+
+- (NSString*)encodeNSString:(NSString*)object
+{
+ return [NSString stringWithFormat:@"@\"%@\"", [object stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"]];
+}
+
+
+- (NSString*)encodeNSNumber:(NSNumber*)object
+{
+ return [NSString stringWithFormat:@"[NSNumber numberWithLongLong:%@]", object];
+}
+*/
+
+
+@end
diff --git a/libPhoneNumber/NBPhoneNumber.h b/libPhoneNumber/NBPhoneNumber.h
new file mode 100644
index 0000000..dfa3b17
--- /dev/null
+++ b/libPhoneNumber/NBPhoneNumber.h
@@ -0,0 +1,25 @@
+//
+// NBPhoneNumber.h
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import <Foundation/Foundation.h>
+#import "NBPhoneNumberDefines.h"
+
+@interface NBPhoneNumber : NSObject <NSCopying>
+
+// from phonemetadata.pb.js
+/* 1 */ @property (nonatomic, strong, readwrite) NSNumber *countryCode;
+/* 2 */ @property (nonatomic, strong, readwrite) NSNumber *nationalNumber;
+/* 3 */ @property (nonatomic, strong, readwrite) NSString *extension;
+/* 4 */ @property (nonatomic, assign, readwrite) BOOL italianLeadingZero;
+/* 5 */ @property (nonatomic, strong, readwrite) NSString *rawInput;
+/* 6 */ @property (nonatomic, strong, readwrite) NSNumber *countryCodeSource;
+/* 7 */ @property (nonatomic, strong, readwrite) NSString *preferredDomesticCarrierCode;
+
+- (void)clearCountryCodeSource;
+- (NBECountryCodeSource)getCountryCodeSourceOrDefault;
+
+@end
\ No newline at end of file
diff --git a/libPhoneNumber/NBPhoneNumber.m b/libPhoneNumber/NBPhoneNumber.m
new file mode 100644
index 0000000..cd79761
--- /dev/null
+++ b/libPhoneNumber/NBPhoneNumber.m
@@ -0,0 +1,121 @@
+//
+// NBPhoneNumber.m
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import "NBPhoneNumber.h"
+#import "NBPhoneNumberDefines.h"
+
+@implementation NBPhoneNumber
+
+@synthesize countryCode, nationalNumber, extension, italianLeadingZero, rawInput, countryCodeSource, preferredDomesticCarrierCode;
+
+- (id)init
+{
+ self = [super init];
+
+ if (self)
+ {
+ self.countryCodeSource = nil;
+ self.italianLeadingZero = NO;
+ self.nationalNumber = @-1;
+ self.countryCode = @-1;
+ }
+
+ return self;
+}
+
+
+- (void)clearCountryCodeSource
+{
+ [self setCountryCodeSource:nil];
+}
+
+
+- (NBECountryCodeSource)getCountryCodeSourceOrDefault
+{
+ if (self.countryCodeSource == nil)
+ return NBECountryCodeSourceFROM_NUMBER_WITH_PLUS_SIGN;
+
+ return [self.countryCodeSource intValue];
+}
+
+
+- (BOOL)isEqualToObject:(NBPhoneNumber*)otherObj
+{
+ return [self isEqual:otherObj];
+}
+
+
+- (NSUInteger)hash
+{
+ NSData *selfObject = [NSKeyedArchiver archivedDataWithRootObject:self];
+ return [selfObject hash];
+}
+
+
+- (BOOL)isEqual:(id)object
+{
+ if ([object isKindOfClass:[NBPhoneNumber class]] == NO)
+ return NO;
+
+ NBPhoneNumber *other = object;
+ return ([self.countryCode isEqualToNumber: other.countryCode]) && ([self.nationalNumber isEqualToNumber: other.nationalNumber]) &&
+ (self.italianLeadingZero == other.italianLeadingZero) &&
+ ((self.extension == nil && other.extension == nil) || [self.extension isEqualToString:other.extension]);
+}
+
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ NBPhoneNumber *phoneNumberCopy = [[NBPhoneNumber allocWithZone:zone] init];
+
+ phoneNumberCopy.countryCode = [self.countryCode copy];
+ phoneNumberCopy.nationalNumber = [self.nationalNumber copy];
+ phoneNumberCopy.extension = [self.extension copy];
+ phoneNumberCopy.italianLeadingZero = self.italianLeadingZero;
+ phoneNumberCopy.rawInput = [self.rawInput copy];
+ phoneNumberCopy.countryCodeSource = [self.countryCodeSource copy];
+ phoneNumberCopy.preferredDomesticCarrierCode = [self.preferredDomesticCarrierCode copy];
+
+ return phoneNumberCopy;
+}
+
+
+- (id)initWithCoder:(NSCoder*)coder
+{
+ if (self = [super init])
+ {
+ self.countryCode = [coder decodeObjectForKey:@"countryCode"];
+ self.nationalNumber = [coder decodeObjectForKey:@"nationalNumber"];
+ self.extension = [coder decodeObjectForKey:@"extension"];
+ self.italianLeadingZero = [[coder decodeObjectForKey:@"italianLeadingZero"] boolValue];
+ self.rawInput = [coder decodeObjectForKey:@"rawInput"];
+ self.countryCodeSource = [coder decodeObjectForKey:@"countryCodeSource"];
+ self.preferredDomesticCarrierCode = [coder decodeObjectForKey:@"preferredDomesticCarrierCode"];
+ }
+ return self;
+}
+
+
+- (void)encodeWithCoder:(NSCoder*)coder
+{
+ [coder encodeObject:self.countryCode forKey:@"countryCode"];
+ [coder encodeObject:self.nationalNumber forKey:@"nationalNumber"];
+ [coder encodeObject:self.extension forKey:@"extension"];
+ [coder encodeObject:[NSNumber numberWithBool:self.italianLeadingZero] forKey:@"italianLeadingZero"];
+ [coder encodeObject:self.rawInput forKey:@"rawInput"];
+ [coder encodeObject:self.countryCodeSource forKey:@"countryCodeSource"];
+ [coder encodeObject:self.preferredDomesticCarrierCode forKey:@"preferredDomesticCarrierCode"];
+}
+
+
+
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@" - countryCode[%@], nationalNumber[%@], extension[%@], italianLeadingZero[%@], rawInput[%@] countryCodeSource[%d] preferredDomesticCarrierCode[%@]", self.countryCode, self.nationalNumber, self.extension, self.italianLeadingZero?@"Y":@"N", self.rawInput, [self.countryCodeSource intValue], self.preferredDomesticCarrierCode];
+}
+
+@end
diff --git a/libPhoneNumber/NBPhoneNumberDefines.h b/libPhoneNumber/NBPhoneNumberDefines.h
new file mode 100644
index 0000000..f7c9bf8
--- /dev/null
+++ b/libPhoneNumber/NBPhoneNumberDefines.h
@@ -0,0 +1,107 @@
+//
+// NBPhoneNumberDefines.h
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#ifndef libPhoneNumber_NBPhoneNumberDefines_h
+#define libPhoneNumber_NBPhoneNumberDefines_h
+
+#define NB_YES [NSNumber numberWithBool:YES]
+#define NB_NO [NSNumber numberWithBool:NO]
+
+#pragma mark - Enum -
+
+typedef enum {
+ NBEPhoneNumberFormatE164 = 0,
+ NBEPhoneNumberFormatINTERNATIONAL = 1,
+ NBEPhoneNumberFormatNATIONAL = 2,
+ NBEPhoneNumberFormatRFC3966 = 3
+} NBEPhoneNumberFormat;
+
+
+typedef enum {
+ NBEPhoneNumberTypeFIXED_LINE = 0,
+ NBEPhoneNumberTypeMOBILE = 1,
+ // In some regions (e.g. the USA), it is impossible to distinguish between
+ // fixed-line and mobile numbers by looking at the phone number itself.
+ NBEPhoneNumberTypeFIXED_LINE_OR_MOBILE = 2,
+ // Freephone lines
+ NBEPhoneNumberTypeTOLL_FREE = 3,
+ NBEPhoneNumberTypePREMIUM_RATE = 4,
+ // The cost of this call is shared between the caller and the recipient, and
+ // is hence typically less than PREMIUM_RATE calls. See
+ // http://en.wikipedia.org/wiki/Shared_Cost_Service for more information.
+ NBEPhoneNumberTypeSHARED_COST = 5,
+ // Voice over IP numbers. This includes TSoIP (Telephony Service over IP).
+ NBEPhoneNumberTypeVOIP = 6,
+ // A personal number is associated with a particular person, and may be routed
+ // to either a MOBILE or FIXED_LINE number. Some more information can be found
+ // here = http://en.wikipedia.org/wiki/Personal_Numbers
+ NBEPhoneNumberTypePERSONAL_NUMBER = 7,
+ NBEPhoneNumberTypePAGER = 8,
+ // Used for 'Universal Access Numbers' or 'Company Numbers'. They may be
+ // further routed to specific offices, but allow one number to be used for a
+ // company.
+ NBEPhoneNumberTypeUAN = 9,
+ // Used for 'Voice Mail Access Numbers'.
+ NBEPhoneNumberTypeVOICEMAIL = 10,
+ // A phone number is of type UNKNOWN when it does not fit any of the known
+ // patterns for a specific region.
+ NBEPhoneNumberTypeUNKNOWN = -1
+} NBEPhoneNumberType;
+
+
+typedef enum {
+ NBEMatchTypeNOT_A_NUMBER = 0,
+ NBEMatchTypeNO_MATCH = 1,
+ NBEMatchTypeSHORT_NSN_MATCH = 2,
+ NBEMatchTypeNSN_MATCH = 3,
+ NBEMatchTypeEXACT_MATCH = 4
+} NBEMatchType;
+
+
+typedef enum {
+ NBEValidationResultIS_POSSIBLE = 0,
+ NBEValidationResultINVALID_COUNTRY_CODE = 1,
+ NBEValidationResultTOO_SHORT = 2,
+ NBEValidationResultTOO_LONG = 3
+} NBEValidationResult;
+
+
+typedef enum {
+ NBECountryCodeSourceFROM_NUMBER_WITH_PLUS_SIGN = 1,
+ NBECountryCodeSourceFROM_NUMBER_WITH_IDD = 5,
+ NBECountryCodeSourceFROM_NUMBER_WITHOUT_PLUS_SIGN = 10,
+ NBECountryCodeSourceFROM_DEFAULT_COUNTRY = 20
+} NBECountryCodeSource;
+
+
+@interface NSArray (NBAdditions)
+
+- (id)safeObjectAtIndex:(NSUInteger)index;
+
+@end
+
+
+@implementation NSArray (NBAdditions)
+
+- (id)safeObjectAtIndex:(NSUInteger)index
+{
+ @synchronized(self)
+ {
+ if(index >= [self count]) return nil;
+
+ id res = [self objectAtIndex:index];
+
+ if (res == nil || (NSNull*)res == [NSNull null])
+ return nil;
+
+ return res;
+ }
+}
+
+@end
+
+#endif
diff --git a/libPhoneNumber/NBPhoneNumberDesc.h b/libPhoneNumber/NBPhoneNumberDesc.h
new file mode 100644
index 0000000..288727c
--- /dev/null
+++ b/libPhoneNumber/NBPhoneNumberDesc.h
@@ -0,0 +1,19 @@
+//
+// NBPhoneNumberDesc.h
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import <Foundation/Foundation.h>
+
+@interface NBPhoneNumberDesc : NSObject
+
+// from phonemetadata.pb.js
+/* 2 */ @property (nonatomic, strong, readwrite) NSString *nationalNumberPattern;
+/* 3 */ @property (nonatomic, strong, readwrite) NSString *possibleNumberPattern;
+/* 6 */ @property (nonatomic, strong, readwrite) NSString *exampleNumber;
+
+- (id)initWithData:(id)data;
+
+@end
diff --git a/libPhoneNumber/NBPhoneNumberDesc.m b/libPhoneNumber/NBPhoneNumberDesc.m
new file mode 100644
index 0000000..f698103
--- /dev/null
+++ b/libPhoneNumber/NBPhoneNumberDesc.m
@@ -0,0 +1,90 @@
+//
+// NBPhoneNumberDesc.m
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import "NBPhoneNumberDesc.h"
+#import "NBPhoneNumberDefines.h"
+
+@implementation NBPhoneNumberDesc
+
+@synthesize nationalNumberPattern, possibleNumberPattern, exampleNumber;
+
+
+- (id)initWithData:(id)data
+{
+ self = [self init];
+
+ if (self && data != nil && [data isKindOfClass:[NSArray class]])
+ {
+ /* 2 */ self.nationalNumberPattern = [data safeObjectAtIndex:2];
+ /* 3 */ self.possibleNumberPattern = [data safeObjectAtIndex:3];
+ /* 6 */ self.exampleNumber = [data safeObjectAtIndex:6];
+ }
+
+ return self;
+}
+
+
+- (id)init
+{
+ self = [super init];
+
+ if (self)
+ {
+ }
+
+ return self;
+}
+
+
+- (id)initWithCoder:(NSCoder*)coder
+{
+ if (self = [super init])
+ {
+ self.nationalNumberPattern = [coder decodeObjectForKey:@"nationalNumberPattern"];
+ self.possibleNumberPattern = [coder decodeObjectForKey:@"possibleNumberPattern"];
+ self.exampleNumber = [coder decodeObjectForKey:@"exampleNumber"];
+ }
+ return self;
+}
+
+
+- (void)encodeWithCoder:(NSCoder*)coder
+{
+ [coder encodeObject:self.nationalNumberPattern forKey:@"nationalNumberPattern"];
+ [coder encodeObject:self.possibleNumberPattern forKey:@"possibleNumberPattern"];
+ [coder encodeObject:self.exampleNumber forKey:@"exampleNumber"];
+}
+
+
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@"nationalNumberPattern[%@] possibleNumberPattern[%@] exampleNumber[%@]", self.nationalNumberPattern, self.possibleNumberPattern, self.exampleNumber];
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ NBPhoneNumberDesc *phoneDescCopy = [[NBPhoneNumberDesc allocWithZone:zone] init];
+
+ phoneDescCopy.nationalNumberPattern = [self.nationalNumberPattern copy];
+ phoneDescCopy.possibleNumberPattern = [self.possibleNumberPattern copy];
+ phoneDescCopy.exampleNumber = [self.exampleNumber copy];
+
+ return phoneDescCopy;
+}
+
+- (BOOL)isEqual:(id)object
+{
+ if ([object isKindOfClass:[NBPhoneNumberDesc class]] == NO)
+ return NO;
+
+ NBPhoneNumberDesc *other = object;
+ return [self.nationalNumberPattern isEqual:other.nationalNumberPattern] &&
+ [self.possibleNumberPattern isEqual:other.possibleNumberPattern] &&
+ [self.exampleNumber isEqual:other.exampleNumber];
+}
+
+@end
diff --git a/libPhoneNumber/NBPhoneNumberMetadata.plist b/libPhoneNumber/NBPhoneNumberMetadata.plist
new file mode 100644
index 0000000..8cd2d03
--- /dev/null
+++ b/libPhoneNumber/NBPhoneNumberMetadata.plist
Binary files differ
diff --git a/libPhoneNumber/NBPhoneNumberMetadataForTesting.plist b/libPhoneNumber/NBPhoneNumberMetadataForTesting.plist
new file mode 100644
index 0000000..2be2ef9
--- /dev/null
+++ b/libPhoneNumber/NBPhoneNumberMetadataForTesting.plist
Binary files differ
diff --git a/libPhoneNumber/NBPhoneNumberUtil.h b/libPhoneNumber/NBPhoneNumberUtil.h
new file mode 100644
index 0000000..e9e13ec
--- /dev/null
+++ b/libPhoneNumber/NBPhoneNumberUtil.h
@@ -0,0 +1,108 @@
+//
+// NBPhoneNumberUtil.h
+// Band
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import <Foundation/Foundation.h>
+#import "NBPhoneNumberDefines.h"
+
+@class NBPhoneMetaData, NBPhoneNumber;
+
+@interface NBPhoneNumberUtil : NSObject
+
++ (NBPhoneNumberUtil*)sharedInstance;
++ (NBPhoneNumberUtil*)sharedInstanceForTest;
+
+// regular expressions
+- (NSArray*)matchesByRegex:(NSString*)sourceString regex:(NSString*)pattern;
+- (NSArray*)matchedStringByRegex:(NSString*)sourceString regex:(NSString*)pattern;
+- (NSString*)replaceStringByRegex:(NSString*)sourceString regex:(NSString*)pattern withTemplate:(NSString*)templateString;
+- (NSInteger)stringPositionByRegex:(NSString*)sourceString regex:(NSString*)pattern;
+
+
++ (NSString*)stringByTrimming:(NSString*)aString;
+
+//- (NSString*)numbersOnly:(NSString*)phoneNumber;
+- (NSArray*)regionCodeFromCountryCode:(NSNumber *)countryCodeNumber;
+- (NSString*)countryCodeFromRegionCode:(NSString*)regionCode;
+
+
+// libPhoneNumber Util functions
+- (NSString*)convertAlphaCharactersInNumber:(NSString*)number;
+
+- (NSString*)normalizePhoneNumber:(NSString*)phoneNumber;
+- (NSString*)normalizeDigitsOnly:(NSString*)number;
+
+- (BOOL)isNumberGeographical:(NBPhoneNumber*)phoneNumber;
+
+- (NSString*)extractPossibleNumber:(NSString*)phoneNumber;
+- (NSNumber*)extractCountryCode:(NSString*)fullNumber nationalNumber:(NSString**)nationalNumber;
+
+- (NSString*)getNddPrefixForRegion:(NSString*)regionCode stripNonDigits:(BOOL)stripNonDigits;
+- (NSString*)getNationalSignificantNumber:(NBPhoneNumber*)phoneNumber;
+
+- (NBEPhoneNumberType)getNumberType:(NBPhoneNumber*)phoneNumber;
+
+- (NSNumber*)getCountryCodeForRegion:(NSString*)regionCode;
+
+- (NSString*)getRegionCodeForCountryCode:(NSNumber*)countryCallingCode;
+- (NSArray*)getRegionCodesForCountryCode:(NSNumber*)countryCallingCode;
+- (NSString*)getRegionCodeForNumber:(NBPhoneNumber*)phoneNumber;
+
+- (NBPhoneNumber*)getExampleNumber:(NSString*)regionCode error:(NSError**)error;
+- (NBPhoneNumber*)getExampleNumberForType:(NSString*)regionCode type:(NBEPhoneNumberType)type error:(NSError**)error;
+- (NBPhoneNumber*)getExampleNumberForNonGeoEntity:(NSNumber*)countryCallingCode error:(NSError**)error;
+
+- (NBPhoneMetaData*)getMetadataForNonGeographicalRegion:(NSNumber*)countryCallingCode;
+- (NBPhoneMetaData*)getMetadataForRegion:(NSString*)regionCode;
+
+- (BOOL)canBeInternationallyDialled:(NBPhoneNumber*)number error:(NSError**)error;
+
+- (BOOL)truncateTooLongNumber:(NBPhoneNumber*)number error:(NSError**)error;
+
+- (BOOL)isValidNumber:(NBPhoneNumber*)number;
+- (BOOL)isViablePhoneNumber:(NSString*)phoneNumber;
+- (BOOL)isAlphaNumber:(NSString*)number;
+- (BOOL)isValidNumberForRegion:(NBPhoneNumber*)number regionCode:(NSString*)regionCode;
+- (BOOL)isNANPACountry:(NSString*)regionCode;
+- (BOOL)isLeadingZeroPossible:(NSNumber*)countryCallingCode;
+
+- (NBEValidationResult)isPossibleNumberWithReason:(NBPhoneNumber*)number error:(NSError**)error;
+
+- (BOOL)isPossibleNumber:(NBPhoneNumber*)number error:(NSError**)error;
+- (BOOL)isPossibleNumberString:(NSString*)number regionDialingFrom:(NSString*)regionDialingFrom error:(NSError**)error;
+
+- (NBEMatchType)isNumberMatch:(id)firstNumberIn second:(id)secondNumberIn error:(NSError**)error;
+
+- (NSUInteger)getLengthOfGeographicalAreaCode:(NBPhoneNumber*)phoneNumber error:(NSError**)error;
+- (NSUInteger)getLengthOfNationalDestinationCode:(NBPhoneNumber*)phoneNumber error:(NSError**)error;
+
+- (BOOL)maybeStripNationalPrefixAndCarrierCode:(NSString**)numberStr metadata:(NBPhoneMetaData*)metadata carrierCode:(NSString**)carrierCode error:(NSError**)error;
+- (NBECountryCodeSource)maybeStripInternationalPrefixAndNormalize:(NSString**)numberStr possibleIddPrefix:(NSString*)possibleIddPrefix error:(NSError**)error;
+- (NSNumber*)maybeExtractCountryCode:(NSString*)number metadata:(NBPhoneMetaData*)defaultRegionMetadata
+ nationalNumber:(NSString**)nationalNumber keepRawInput:(BOOL)keepRawInput phoneNumber:(NBPhoneNumber**)phoneNumber error:(NSError**)error;
+
+- (NBPhoneNumber*)parse:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion error:(NSError**)error;
+- (NBPhoneNumber*)parseAndKeepRawInput:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion error:(NSError**)error;
+- (NBPhoneNumber*)parseWithPhoneCarrierRegion:(NSString*)numberToParse error:(NSError**)error;
+
+- (NSString*)format:(NBPhoneNumber*)phoneNumber numberFormat:(NBEPhoneNumberFormat)numberFormat error:(NSError**)error;
+- (NSString*)formatByPattern:(NBPhoneNumber*)number numberFormat:(NBEPhoneNumberFormat)numberFormat userDefinedFormats:(NSArray*)userDefinedFormats error:(NSError**)error;
+- (NSString*)formatNumberForMobileDialing:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom withFormatting:(BOOL)withFormatting error:(NSError**)error;
+- (NSString*)formatOutOfCountryCallingNumber:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom error:(NSError**)error;
+- (NSString*)formatOutOfCountryKeepingAlphaChars:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom error:(NSError**)error;
+- (NSString*)formatNationalNumberWithCarrierCode:(NBPhoneNumber*)number carrierCode:(NSString*)carrierCode error:(NSError**)error;
+- (NSString*)formatInOriginalFormat:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom error:(NSError**)error;
+- (NSString*)formatNationalNumberWithPreferredCarrierCode:(NBPhoneNumber*)number fallbackCarrierCode:(NSString*)fallbackCarrierCode error:(NSError**)error;
+
+- (BOOL)formattingRuleHasFirstGroupOnly:(NSString*)nationalPrefixFormattingRule;
+
+@property (nonatomic, readonly) NSString *VALID_PUNCTUATION;
+@property (nonatomic, readonly) NSString *VALID_DIGITS_STRING;
+@property (nonatomic, readonly) NSString *PLUS_CHARS_;
+@property (nonatomic, readonly) NSString *REGION_CODE_FOR_NON_GEO_ENTITY;
+@property (nonatomic, readonly) NSDictionary *DIGIT_MAPPINGS;
+
+@end
diff --git a/libPhoneNumber/NBPhoneNumberUtil.m b/libPhoneNumber/NBPhoneNumberUtil.m
new file mode 100644
index 0000000..bfb95c9
--- /dev/null
+++ b/libPhoneNumber/NBPhoneNumberUtil.m
@@ -0,0 +1,4305 @@
+//
+// NBPhoneNumberUtil.m
+// Band
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import "NBPhoneNumberUtil.h"
+#import "NBPhoneNumber.h"
+#import "NBNumberFormat.h"
+#import "NBPhoneNumberDesc.h"
+#import "NBPhoneMetaData.h"
+#import "math.h"
+
+#import <CoreTelephony/CTTelephonyNetworkInfo.h>
+#import <CoreTelephony/CTCarrier.h>
+
+
+#pragma mark - Static Int variables -
+const static NSUInteger NANPA_COUNTRY_CODE_ = 1;
+const static NSUInteger MIN_LENGTH_FOR_NSN_ = 2;
+const static NSUInteger MAX_LENGTH_FOR_NSN_ = 16;
+const static NSUInteger MAX_LENGTH_COUNTRY_CODE_ = 3;
+const static NSUInteger MAX_INPUT_STRING_LENGTH_ = 250;
+
+
+#pragma mark - Static String variables -
+NSString *INVALID_COUNTRY_CODE_STR = @"Invalid country calling code";
+NSString *NOT_A_NUMBER_STR = @"The string supplied did not seem to be a phone number";
+NSString *TOO_SHORT_AFTER_IDD_STR = @"Phone number too short after IDD";
+NSString *TOO_SHORT_NSN_STR = @"The string supplied is too short to be a phone number";
+NSString *TOO_LONG_STR = @"The string supplied is too long to be a phone number";
+
+NSString *UNKNOWN_REGION_ = @"ZZ";
+NSString *COLOMBIA_MOBILE_TO_FIXED_LINE_PREFIX_ = @"3";
+NSString *PLUS_SIGN = @"+";
+NSString *STAR_SIGN_ = @"*";
+NSString *RFC3966_EXTN_PREFIX_ = @";ext=";
+NSString *RFC3966_PREFIX_ = @"tel:";
+NSString *RFC3966_PHONE_CONTEXT_ = @";phone-context=";
+NSString *RFC3966_ISDN_SUBADDRESS_ = @";isub=";
+NSString *DEFAULT_EXTN_PREFIX_ = @" ext. ";
+NSString *VALID_ALPHA_ = @"A-Za-z";
+
+#pragma mark - Static regular expression strings -
+NSString *NON_DIGITS_PATTERN_ = @"\\D+";
+NSString *CC_PATTERN_ = @"\\$CC";
+NSString *FIRST_GROUP_PATTERN_ = @"(\\$\\d)";
+NSString *FIRST_GROUP_ONLY_PREFIX_PATTERN_ = @"^\\(?\\$1\\)?";
+NSString *NP_PATTERN_ = @"\\$NP";
+NSString *FG_PATTERN_ = @"\\$FG";
+NSString *VALID_ALPHA_PHONE_PATTERN_STRING = @"(?:.*?[A-Za-z]){3}.*";
+NSString *UNIQUE_INTERNATIONAL_PREFIX_ = @"[\\d]+(?:[~\\u2053\\u223C\\uFF5E][\\d]+)?";
+
+
+#pragma mark - NBPhoneNumberUtil interface -
+@interface NBPhoneNumberUtil ()
+
+/*
+ Terminologies
+ - Country Number (CN) = Country code for i18n calling
+ - Country Code (CC) : ISO country codes (2 chars)
+ Ref. site (countrycode.org)
+ */
+@property (nonatomic, readonly) NSDictionary *coreMetaData;
+@property (nonatomic, readonly) NSRegularExpression *PLUS_CHARS_PATTERN, *CAPTURING_DIGIT_PATTERN, *VALID_ALPHA_PHONE_PATTERN_;
+@property (nonatomic, readonly) NSString *LEADING_PLUS_CHARS_PATTERN_, *EXTN_PATTERN_, *SEPARATOR_PATTERN_, *VALID_PHONE_NUMBER_PATTERN_, *VALID_START_CHAR_PATTERN_, *UNWANTED_END_CHAR_PATTERN_, *SECOND_NUMBER_START_PATTERN_;
+
+@property (nonatomic, readonly) NSDictionary *ALPHA_MAPPINGS_, *ALL_NORMALIZATION_MAPPINGS_, *DIALLABLE_CHAR_MAPPINGS_, *ALL_PLUS_NUMBER_GROUPING_SYMBOLS_;
+
+@property (nonatomic, strong, readwrite) NSMutableDictionary *mapCCode2CN;
+@property (nonatomic, strong, readwrite) NSMutableDictionary *mapCN2CCode;
+
+@property (nonatomic, strong, readwrite) NSMutableDictionary *i18nNumberFormat;
+@property (nonatomic, strong, readwrite) NSMutableDictionary *i18nPhoneNumberDesc;
+@property (nonatomic, strong, readwrite) NSMutableDictionary *i18nPhoneMetadata;
+
+@end
+
+
+@implementation NBPhoneNumberUtil
+
++ (NBPhoneNumberUtil*)sharedInstance
+{
+ static NBPhoneNumberUtil *sharedOnceInstance = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{ sharedOnceInstance = [[self alloc] init]; });
+ return sharedOnceInstance;
+}
+
+
++ (NBPhoneNumberUtil*)sharedInstanceForTest
+{
+ static NBPhoneNumberUtil *sharedOnceInstanceForTest = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{ sharedOnceInstanceForTest = [[self alloc] initForTest]; });
+ return sharedOnceInstanceForTest;
+}
+
+
++ (NSString*)stringByTrimming:(NSString*)aString
+{
+ NSString *aRes = @"";
+ NSArray *newlines = [aString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
+ for (NSString *line in newlines)
+ {
+ NSString *performedString = [line stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+
+ if (performedString.length > 0)
+ aRes = [aRes stringByAppendingString:performedString];
+ }
+
+ if (newlines.count <= 0)
+ return aString;
+
+ return aRes;
+}
+
+
+#pragma mark - Regular expression Utilities -
+- (BOOL)hasValue:(NSString*)string
+{
+ if (string == nil || [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length <= 0)
+ {
+ return NO;
+ }
+
+ return YES;
+}
+
+
+- (NSMutableArray*)componentsSeparatedByRegex:(NSString*)sourceString regex:(NSString*)pattern
+{
+ NSString *replacedString = [self replaceStringByRegex:sourceString regex:pattern withTemplate:@"<SEP>"];
+ NSMutableArray *resArray = [[replacedString componentsSeparatedByString:@"<SEP>"] mutableCopy];
+ [resArray removeObject:@""];
+ return resArray;
+}
+
+
+- (NSInteger)stringPositionByRegex:(NSString*)sourceString regex:(NSString*)pattern
+{
+ if (sourceString == nil || sourceString.length <= 0 || pattern == nil || pattern.length <= 0) {
+ return -1;
+ }
+
+ NSError *error = nil;
+ NSRegularExpression *currentPattern = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
+ NSArray *matches = [currentPattern matchesInString:sourceString options:0 range:NSMakeRange(0, sourceString.length)];
+
+ NSInteger foundPosition = -1;
+
+ if (matches.count > 0)
+ {
+ NSTextCheckingResult *match = [matches objectAtIndex:0];
+ return match.range.location;
+ }
+
+ return foundPosition;
+}
+
+
+- (NSInteger)indexOfStringByString:(NSString*)sourceString target:(NSString*)targetString
+{
+ NSRange finded = [sourceString rangeOfString:targetString];
+ if (finded.location != NSNotFound)
+ {
+ return finded.location;
+ }
+
+ return -1;
+}
+
+
+- (NSString*)replaceFirstStringByRegex:(NSString*)sourceString regex:(NSString*)pattern withTemplate:(NSString*)templateString
+{
+ NSString *replacementResult = [sourceString copy];
+ NSError *error = nil;
+
+ NSRegularExpression *currentPattern = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
+ NSRange replaceRange = [currentPattern rangeOfFirstMatchInString:sourceString options:0 range:NSMakeRange(0, sourceString.length)];
+
+ if (replaceRange.location != NSNotFound)
+ {
+ replacementResult = [currentPattern stringByReplacingMatchesInString:[sourceString mutableCopy] options:0
+ range:replaceRange
+ withTemplate:templateString];
+ }
+
+ return replacementResult;
+}
+
+
+- (NSString*)replaceStringByRegex:(NSString*)sourceString regex:(NSString*)pattern withTemplate:(NSString*)templateString
+{
+ NSString *replacementResult = [sourceString copy];
+ NSError *error = nil;
+
+ NSRegularExpression *currentPattern = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
+ NSArray *matches = [currentPattern matchesInString:sourceString options:0 range:NSMakeRange(0, sourceString.length)];
+
+ if ([matches count] == 1)
+ {
+ NSRange replaceRange = [currentPattern rangeOfFirstMatchInString:sourceString options:0 range:NSMakeRange(0, sourceString.length)];
+
+ if (replaceRange.location != NSNotFound)
+ {
+ replacementResult = [currentPattern stringByReplacingMatchesInString:[sourceString mutableCopy] options:0
+ range:replaceRange
+ withTemplate:templateString];
+ }
+ return replacementResult;
+ }
+
+ if ([matches count] > 1)
+ {
+ replacementResult = [currentPattern stringByReplacingMatchesInString:[replacementResult mutableCopy] options:0
+ range:NSMakeRange(0, sourceString.length) withTemplate:templateString];
+ return replacementResult;
+ }
+
+ return replacementResult;
+}
+
+
+- (NSTextCheckingResult*)matcheFirstByRegex:(NSString*)sourceString regex:(NSString*)pattern
+{
+ NSError *error = nil;
+ NSRegularExpression *currentPattern = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
+ NSArray *matches = [currentPattern matchesInString:sourceString options:0 range:NSMakeRange(0, sourceString.length)];
+ if ([matches count] > 0)
+ return [matches objectAtIndex:0];
+ return nil;
+}
+
+
+- (NSArray*)matchesByRegex:(NSString*)sourceString regex:(NSString*)pattern
+{
+ NSError *error = nil;
+ NSRegularExpression *currentPattern = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
+ NSArray *matches = [currentPattern matchesInString:sourceString options:0 range:NSMakeRange(0, sourceString.length)];
+ return matches;
+}
+
+
+- (NSArray*)matchedStringByRegex:(NSString*)sourceString regex:(NSString*)pattern
+{
+ NSArray *matches = [self matchesByRegex:sourceString regex:pattern];
+ NSMutableArray *matchString = [[NSMutableArray alloc] init];
+
+ for (NSTextCheckingResult *match in matches)
+ {
+ NSString *curString = [sourceString substringWithRange:match.range];
+ [matchString addObject:curString];
+ }
+
+ return matchString;
+}
+
+
+- (BOOL)isStartingStringByRegex:(NSString*)sourceString regex:(NSString*)pattern
+{
+ NSError *error = nil;
+ NSRegularExpression *currentPattern = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:&error];
+ NSArray *matches = [currentPattern matchesInString:sourceString options:0 range:NSMakeRange(0, sourceString.length)];
+
+ for (NSTextCheckingResult *match in matches)
+ {
+ if (match.range.location == 0)
+ {
+ return YES;
+ }
+ }
+
+ return NO;
+}
+
+
+- (NSString*)stringByReplacingOccurrencesString:(NSString *)sourceString withMap:(NSDictionary *)dicMap removeNonMatches:(BOOL)bRemove
+{
+ NSMutableString *targetString = [[NSMutableString alloc] initWithString:@""];
+
+ for(NSUInteger i=0; i<sourceString.length; i++)
+ {
+ unichar oneChar = [sourceString characterAtIndex:i];
+ NSString *keyString = [NSString stringWithCharacters:&oneChar length:1];
+ NSString *mappedValue = [dicMap objectForKey:keyString];
+ if (mappedValue != nil)
+ {
+ [targetString appendString:mappedValue];
+ }
+ else
+ {
+ if (bRemove == NO)
+ {
+ [targetString appendString:keyString];
+ }
+ }
+ }
+
+ return targetString;
+}
+
+
+- (BOOL)isNaN:(NSString*)sourceString
+{
+ NSCharacterSet *alphaNums = [NSCharacterSet decimalDigitCharacterSet];
+ NSCharacterSet *inStringSet = [NSCharacterSet characterSetWithCharactersInString:sourceString];
+ BOOL hasNumberOnly = [alphaNums isSupersetOfSet:inStringSet];
+
+ return !hasNumberOnly;
+}
+
+/*
+ - (NSString*)numbersOnly:(NSString*)phoneNumber
+ {
+ NSMutableString *strippedString = [NSMutableString stringWithCapacity:phoneNumber.length];
+
+ NSScanner *scanner = [NSScanner scannerWithString:phoneNumber];
+ NSCharacterSet *numbers = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
+
+ while ([scanner isAtEnd] == NO) {
+ NSString *buffer;
+ if ([scanner scanCharactersFromSet:numbers intoString:&buffer]) {
+ [strippedString appendString:buffer];
+
+ } else {
+ [scanner setScanLocation:([scanner scanLocation] + 1)];
+ }
+ }
+
+ return strippedString;
+ }
+ */
+
+
+- (NSString*)getNationalSignificantNumber:(NBPhoneNumber*)phoneNumber
+{
+ if (phoneNumber.italianLeadingZero)
+ {
+ return [NSString stringWithFormat:@"0%@", phoneNumber.nationalNumber];
+ }
+
+ return [NSString stringWithFormat:@"%@", phoneNumber.nationalNumber];
+}
+
+
+- (NSArray*)regionCodeFromCountryCode:(NSNumber *)countryCodeNumber
+{
+ if (self.mapCN2CCode == nil || [self.mapCN2CCode count] <= 0)
+ {
+ return nil;
+ }
+
+ id res = [self.mapCN2CCode objectForKey:[NSString stringWithFormat:@"%@", countryCodeNumber]];
+
+ if (res && [res isKindOfClass:[NSArray class]] && [((NSArray*)res) count] > 0)
+ {
+ return res;
+ }
+
+ return nil;
+}
+
+
+- (NSString*)countryCodeFromRegionCode:(NSString*)regionCode
+{
+ if (self.mapCCode2CN == nil || [self.mapCCode2CN count] <= 0)
+ {
+ return nil;
+ }
+
+ id res = [self.mapCCode2CN objectForKey:regionCode];
+
+ if (res)
+ {
+ return res;
+ }
+
+ return nil;
+}
+
+
+#pragma mark - Initializations -
+- (id)init
+{
+ self = [super init];
+ if (self)
+ {
+ [self initRegularExpressionSet];
+ [self initNormalizationMappings];
+
+ NSDictionary *resData = [self loadMetadata:@"NBPhoneNumberMetadata"];
+ _coreMetaData = [resData objectForKey:@"countryToMetadata"];
+ _mapCN2CCode = [resData objectForKey:@"countryCodeToRegionCodeMap"];
+
+ [self initCC2CN];
+ }
+
+ return self;
+}
+
+
+- (id)initForTest
+{
+ self = [super init];
+ if (self)
+ {
+ [self initRegularExpressionSet];
+ [self initNormalizationMappings];
+
+ NSDictionary *resData = [self loadMetadata:@"NBPhoneNumberMetadataForTesting"];
+ _coreMetaData = [resData objectForKey:@"countryToMetadata"];
+ _mapCN2CCode = [resData objectForKey:@"countryCodeToRegionCodeMap"];
+
+ [self initCC2CN];
+ }
+
+ return self;
+}
+
+
+- (NSDictionary*)loadMetadata:(NSString*)name
+{
+ NSDictionary *unarchiveData = nil;
+
+ @try {
+ NSString *filePath = [[NSBundle mainBundle] pathForResource:name ofType:@"plist"];
+ NSData *fileData = [NSData dataWithContentsOfFile:filePath];
+ unarchiveData = [NSKeyedUnarchiver unarchiveObjectWithData:fileData];
+ }
+ @catch (NSException *exception) {
+ return unarchiveData;
+ }
+
+ return unarchiveData;
+}
+
+/*
+ - (NSDictionary*)generateMetadata:(id)metaClass
+ {
+ NSMutableDictionary *resMedata = [[NSMutableDictionary alloc] init];
+ NSDictionary *srcMedata = nil;
+
+ if ([metaClass isKindOfClass:[NBPhoneNumberMetadataForTesting class]])
+ {
+ srcMedata = ((NBPhoneNumberMetadataForTesting*)metaClass).metadata;
+ }
+ else if ([metaClass isKindOfClass:[NBPhoneNumberMetadata class]])
+ {
+ srcMedata = ((NBPhoneNumberMetadata*)metaClass).metadata;
+ }
+ else
+ {
+ return resMedata;
+ }
+
+ NSDictionary *countryCodeToRegionCodeMap = [srcMedata objectForKey:@"countryCodeToRegionCodeMap"];
+ NSDictionary *countryToMetadata = [srcMedata objectForKey:@"countryToMetadata"];
+ NSLog(@"- countryCodeToRegionCodeMap count [%d]", [countryCodeToRegionCodeMap count]);
+ NSLog(@"- countryToMetadata count [%d]", [countryToMetadata count]);
+
+ NSMutableDictionary *genetatedMetaData = [[NSMutableDictionary alloc] init];
+
+ for (id key in [countryToMetadata allKeys])
+ {
+ id metaData = [countryToMetadata objectForKey:key];
+
+ NBPhoneMetaData *newMetaData = [[NBPhoneMetaData alloc] init];
+ [newMetaData buildData:metaData];
+
+ [genetatedMetaData setObject:newMetaData forKey:key];
+ }
+
+ [resMedata setObject:countryCodeToRegionCodeMap forKey:@"countryCodeToRegionCodeMap"];
+ [resMedata setObject:genetatedMetaData forKey:@"countryToMetadata"];
+
+ return resMedata;
+ }
+ */
+
+
+- (void)initRegularExpressionSet
+{
+ _VALID_PUNCTUATION = @"-x‐-―−ー--/ ()()[].\\[\\]/~⁓∼~";
+ _VALID_DIGITS_STRING = @"0-90-9٠-٩۰-۹";
+ _PLUS_CHARS_ = @"++";
+ _REGION_CODE_FOR_NON_GEO_ENTITY = @"001";
+
+ NSString *EXTN_PATTERNS_FOR_PARSING_ = @"(?:;ext=([0-90-9٠-٩۰-۹]{1,7})|[ \\t,]*(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|[,xxX##~~]|int|anexo|int)[:\\..]?[ \\t,-]*([0-90-9٠-٩۰-۹]{1,7})#?|[- ]+([0-90-9٠-٩۰-۹]{1,5})#)$";
+
+ NSError *error = nil;
+
+ _PLUS_CHARS_PATTERN =
+ [NSRegularExpression regularExpressionWithPattern:[NSString stringWithFormat:@"[%@]+", _PLUS_CHARS_] options:0 error:&error];
+
+ _LEADING_PLUS_CHARS_PATTERN_ = [NSString stringWithFormat:@"^[%@]+", _PLUS_CHARS_];
+
+ _CAPTURING_DIGIT_PATTERN =
+ [NSRegularExpression regularExpressionWithPattern:[NSString stringWithFormat:@"([%@])", _VALID_DIGITS_STRING] options:0 error:&error];
+
+ _VALID_START_CHAR_PATTERN_ = [NSString stringWithFormat:@"[%@%@]", _PLUS_CHARS_, _VALID_DIGITS_STRING];
+
+ _SECOND_NUMBER_START_PATTERN_ = @"[\\\\\\/] *x";
+
+ _VALID_ALPHA_PHONE_PATTERN_ = [NSRegularExpression regularExpressionWithPattern:VALID_ALPHA_PHONE_PATTERN_STRING options:0 error:&error];
+
+ _UNWANTED_END_CHAR_PATTERN_ = [NSString stringWithFormat:@"[^%@%@#]+$", _VALID_DIGITS_STRING, VALID_ALPHA_];
+
+ _EXTN_PATTERN_ = [NSString stringWithFormat:@"(?:%@)$", EXTN_PATTERNS_FOR_PARSING_];
+
+
+ _SEPARATOR_PATTERN_ = [NSString stringWithFormat:@"[%@]+", _VALID_PUNCTUATION];
+
+ _VALID_PHONE_NUMBER_PATTERN_ = @"^[0-90-9٠-٩۰-۹]{2}$|^[++]*(?:[-x‐-―−ー--/ ()()[].\\[\\]/~⁓∼~*]*[0-90-9٠-٩۰-۹]){3,}[-x‐-―−ー--/ ()()[].\\[\\]/~⁓∼~*A-Za-z0-90-9٠-٩۰-۹]*(?:;ext=([0-90-9٠-٩۰-۹]{1,7})|[ \\t,]*(?:e?xt(?:ensi(?:ó?|ó))?n?|e?xtn?|[,xx##~~]|int|anexo|int)[:\\..]?[ \\t,-]*([0-90-9٠-٩۰-۹]{1,7})#?|[- ]+([0-90-9٠-٩۰-۹]{1,5})#)?$";
+}
+
+
+- (void)dealloc
+{
+ [self clearCC2CN];
+ [self clearCN2CC];
+}
+
+
+- (void)clearCC2CN
+{
+ if (self.mapCCode2CN != nil)
+ {
+ [self.mapCCode2CN removeAllObjects];
+ self.mapCCode2CN = nil;
+ }
+}
+
+
+- (void)clearCN2CC
+{
+ if (self.mapCN2CCode != nil)
+ {
+ [self.mapCN2CCode removeAllObjects];
+ self.mapCN2CCode = nil;
+ }
+}
+
+
+- (void)initNormalizationMappings
+{
+ _DIGIT_MAPPINGS = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ @"0", @"0", @"1", @"1", @"2", @"2", @"3", @"3", @"4", @"4", @"5", @"5", @"6", @"6", @"7", @"7", @"8", @"8", @"9", @"9",
+ // Fullwidth digit 0 to 9
+ @"0", @"\uFF10", @"1", @"\uFF11", @"2", @"\uFF12", @"3", @"\uFF13", @"4", @"\uFF14", @"5", @"\uFF15", @"6", @"\uFF16", @"7", @"\uFF17", @"8", @"\uFF18", @"9", @"\uFF19",
+ // Arabic-indic digit 0 to 9
+ @"0", @"\u0660", @"1", @"\u0661", @"2", @"\u0662", @"3", @"\u0663", @"4", @"\u0664", @"5", @"\u0665", @"6", @"\u0666", @"7", @"\u0667", @"8", @"\u0668", @"9", @"\u0669",
+ // Eastern-Arabic digit 0 to 9
+ @"0", @"\u06F0", @"1", @"\u06F1", @"2", @"\u06F2", @"3", @"\u06F3", @"4", @"\u06F4", @"5", @"\u06F5", @"6", @"\u06F6", @"7", @"\u06F7", @"8", @"\u06F8", @"9", @"\u06F9", nil];
+
+ _DIALLABLE_CHAR_MAPPINGS_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ @"0", @"0", @"1", @"1", @"2", @"2", @"3", @"3", @"4", @"4", @"5", @"5", @"6", @"6", @"7", @"7", @"8", @"8", @"9", @"9",
+ @"+", @"+", @"*", @"*", nil];
+
+ _ALPHA_MAPPINGS_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ @"2", @"A", @"2", @"B", @"2", @"C", @"3", @"D", @"3", @"E", @"3", @"F", @"4", @"G", @"4", @"H", @"4", @"I", @"5", @"J",
+ @"5", @"K", @"5", @"L", @"6", @"M", @"6", @"N", @"6", @"O", @"7", @"P", @"7", @"Q", @"7", @"R", @"7", @"S", @"8", @"T",
+ @"8", @"U", @"8", @"V", @"9", @"W", @"9", @"X", @"9", @"Y", @"9", @"Z", nil];
+
+ _ALL_NORMALIZATION_MAPPINGS_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ @"0", @"0", @"1", @"1", @"2", @"2", @"3", @"3", @"4", @"4", @"5", @"5", @"6", @"6", @"7", @"7", @"8", @"8", @"9", @"9",
+ // Fullwidth digit 0 to 9
+ @"0", @"\uFF10", @"1", @"\uFF11", @"2", @"\uFF12", @"3", @"\uFF13", @"4", @"\uFF14", @"5", @"\uFF15", @"6", @"\uFF16", @"7", @"\uFF17", @"8", @"\uFF18", @"9", @"\uFF19",
+ // Arabic-indic digit 0 to 9
+ @"0", @"\u0660", @"1", @"\u0661", @"2", @"\u0662", @"3", @"\u0663", @"4", @"\u0664", @"5", @"\u0665", @"6", @"\u0666", @"7", @"\u0667", @"8", @"\u0668", @"9", @"\u0669",
+ // Eastern-Arabic digit 0 to 9
+ @"0", @"\u06F0", @"1", @"\u06F1", @"2", @"\u06F2", @"3", @"\u06F3", @"4", @"\u06F4", @"5", @"\u06F5", @"6", @"\u06F6", @"7", @"\u06F7", @"8", @"\u06F8", @"9", @"\u06F9",
+ @"2", @"A", @"2", @"B", @"2", @"C", @"3", @"D", @"3", @"E", @"3", @"F", @"4", @"G", @"4", @"H", @"4", @"I", @"5", @"J",
+ @"5", @"K", @"5", @"L", @"6", @"M", @"6", @"N", @"6", @"O", @"7", @"P", @"7", @"Q", @"7", @"R", @"7", @"S", @"8", @"T",
+ @"8", @"U", @"8", @"V", @"9", @"W", @"9", @"X", @"9", @"Y", @"9", @"Z", nil];
+
+ _ALL_PLUS_NUMBER_GROUPING_SYMBOLS_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ @"0", @"0", @"1", @"1", @"2", @"2", @"3", @"3", @"4", @"4", @"5", @"5", @"6", @"6", @"7", @"7", @"8", @"8", @"9", @"9",
+ @"A", @"A", @"B", @"B", @"C", @"C", @"D", @"D", @"E", @"E", @"F", @"F", @"G", @"G", @"H", @"H", @"I", @"I", @"J", @"J",
+ @"K", @"K", @"L", @"L", @"M", @"M", @"N", @"N", @"O", @"O", @"P", @"P", @"Q", @"Q", @"R", @"R", @"S", @"S", @"T", @"T",
+ @"U", @"U", @"V", @"V", @"W", @"W", @"X", @"X", @"Y", @"Y", @"Z", @"Z", @"A", @"a", @"B", @"b", @"C", @"c", @"D", @"d",
+ @"E", @"e", @"F", @"f", @"G", @"g", @"H", @"h", @"I", @"i", @"J", @"j", @"K", @"k", @"L", @"l", @"M", @"m", @"N", @"n",
+ @"O", @"o", @"P", @"p", @"Q", @"q", @"R", @"r", @"S", @"s", @"T", @"t", @"U", @"u", @"V", @"v", @"W", @"w", @"X", @"x",
+ @"Y", @"y", @"Z", @"z", @"-", @"-", @"-", @"\uFF0D", @"-", @"\u2010", @"-", @"\u2011", @"-", @"\u2012", @"-", @"\u2013", @"-", @"\u2014", @"-", @"\u2015",
+ @"-", @"\u2212", @"/", @"/", @"/", @"\uFF0F", @" ", @" ", @" ", @"\u3000", @" ", @"\u2060", @".", @".", @".", @"\uFF0E", nil];
+
+}
+
+
+- (void)initCC2CN
+{
+ [self clearCC2CN];
+ _mapCCode2CN = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ @"1", @"US", @"1", @"AG", @"1", @"AI", @"1", @"AS", @"1", @"BB", @"1", @"BM", @"1", @"BS", @"1", @"CA", @"1", @"DM", @"1", @"DO",
+ @"1", @"GD", @"1", @"GU", @"1", @"JM", @"1", @"KN", @"1", @"KY", @"1", @"LC", @"1", @"MP", @"1", @"MS", @"1", @"PR", @"1", @"SX",
+ @"1", @"TC", @"1", @"TT", @"1", @"VC", @"1", @"VG", @"1", @"VI", @"7", @"RU", @"7", @"KZ",
+ @"20", @"EG", @"27", @"ZA",
+ @"30", @"GR", @"31", @"NL", @"32", @"BE", @"33", @"FR", @"34", @"ES", @"36", @"HU", @"39", @"IT",
+ @"40", @"RO", @"41", @"CH", @"43", @"AT", @"44", @"GB", @"44", @"GG", @"44", @"IM", @"44", @"JE", @"45", @"DK", @"46", @"SE", @"47", @"NO", @"47", @"SJ", @"48", @"PL", @"49", @"DE",
+ @"51", @"PE", @"52", @"MX", @"53", @"CU", @"54", @"AR", @"55", @"BR", @"56", @"CL", @"57", @"CO", @"58", @"VE",
+ @"60", @"MY", @"61", @"AU", @"61", @"CC", @"61", @"CX", @"62", @"ID", @"63", @"PH", @"64", @"NZ", @"65", @"SG", @"66", @"TH",
+ @"81", @"JP", @"82", @"KR", @"84", @"VN", @"86", @"CN",
+ @"90", @"TR", @"91", @"IN", @"92", @"PK", @"93", @"AF", @"94", @"LK", @"95", @"MM", @"98", @"IR",
+ @"211", @"SS", @"212", @"MA", @"212", @"EH", @"213", @"DZ", @"216", @"TN", @"218", @"LY",
+ @"220", @"GM", @"221", @"SN", @"222", @"MR", @"223", @"ML", @"224", @"GN", @"225", @"CI", @"226", @"BF", @"227", @"NE", @"228", @"TG", @"229", @"BJ",
+ @"230", @"MU", @"231", @"LR", @"232", @"SL", @"233", @"GH", @"234", @"NG", @"235", @"TD", @"236", @"CF", @"237", @"CM", @"238", @"CV", @"239", @"ST",
+ @"240", @"GQ", @"241", @"GA", @"242", @"CG", @"243", @"CD", @"244", @"AO", @"245", @"GW", @"246", @"IO", @"247", @"AC", @"248", @"SC", @"249", @"SD",
+ @"250", @"RW", @"251", @"ET", @"252", @"SO", @"253", @"DJ", @"254", @"KE", @"255", @"TZ", @"256", @"UG", @"257", @"BI", @"258", @"MZ",
+ @"260", @"ZM", @"261", @"MG", @"262", @"RE", @"262", @"YT", @"263", @"ZW", @"264", @"NA", @"265", @"MW", @"266", @"LS", @"267", @"BW", @"268", @"SZ", @"269", @"KM",
+ @"290", @"SH", @"291", @"ER", @"297", @"AW", @"298", @"FO", @"299", @"GL",
+ @"350", @"GI", @"351", @"PT", @"352", @"LU", @"353", @"IE", @"354", @"IS", @"355", @"AL", @"356", @"MT", @"357", @"CY", @"358", @"FI",@"358", @"AX", @"359", @"BG",
+ @"370", @"LT", @"371", @"LV", @"372", @"EE", @"373", @"MD", @"374", @"AM", @"375", @"BY", @"376", @"AD", @"377", @"MC", @"378", @"SM", @"379", @"VA",
+ @"380", @"UA", @"381", @"RS", @"382", @"ME", @"385", @"HR", @"386", @"SI", @"387", @"BA", @"389", @"MK",
+ @"420", @"CZ", @"421", @"SK", @"423", @"LI",
+ @"500", @"FK", @"501", @"BZ", @"502", @"GT", @"503", @"SV", @"504", @"HN", @"505", @"NI", @"506", @"CR", @"507", @"PA", @"508", @"PM", @"509", @"HT",
+ @"590", @"GP", @"590", @"BL", @"590", @"MF", @"591", @"BO", @"592", @"GY", @"593", @"EC", @"594", @"GF", @"595", @"PY", @"596", @"MQ", @"597", @"SR", @"598", @"UY", @"599", @"CW", @"599", @"BQ",
+ @"670", @"TL", @"672", @"NF", @"673", @"BN", @"674", @"NR", @"675", @"PG", @"676", @"TO", @"677", @"SB", @"678", @"VU", @"679", @"FJ",
+ @"680", @"PW", @"681", @"WF", @"682", @"CK", @"683", @"NU", @"685", @"WS", @"686", @"KI", @"687", @"NC", @"688", @"TV", @"689", @"PF",
+ @"690", @"TK", @"691", @"FM", @"692", @"MH",
+ @"800", @"001", @"808", @"001",
+ @"850", @"KP", @"852", @"HK", @"853", @"MO", @"855", @"KH", @"856", @"LA",
+ @"870", @"001", @"878", @"001",
+ @"880", @"BD", @"881", @"001", @"882", @"001", @"883", @"001", @"886", @"TW", @"888", @"001",
+ @"960", @"MV", @"961", @"LB", @"962", @"JO", @"963", @"SY", @"964", @"IQ", @"965", @"KW", @"966", @"SA", @"967", @"YE", @"968", @"OM",
+ @"970", @"PS", @"971", @"AE", @"972", @"IL", @"973", @"BH", @"974", @"QA", @"975", @"BT", @"976", @"MN", @"977", @"NP", @"979", @"001",
+ @"992", @"TJ", @"993", @"TM", @"994", @"AZ", @"995", @"GE", @"996", @"KG", @"998", @"UZ",
+ nil];
+}
+
+/*
+ - (void)initCN2CC
+ {
+ [self clearCN2CC];
+ _mapCN2CCode = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ @[@"US", @"AG", @"AI", @"AS", @"BB", @"BM", @"BS", @"CA", @"DM", @"DO", @"GD", @"GU", @"JM", @"KN", @"KY", @"LC", @"MP", @"MS", @"PR", @"SX", @"TC", @"TT", @"VC", @"VG", @"VI"], @"1", @[@"RU", @"KZ"], @"7",
+ @[@"EG"], @"20", @[@"ZA"], @"27",
+ @[@"GR"], @"30", @[@"NL"], @"31", @[@"BE"], @"32", @[@"FR"], @"33", @[@"ES"], @"34", @[@"HU"], @"36", @[@"IT"], @"39",
+ @[@"RO"], @"40", @[@"CH"], @"41", @[@"AT"], @"43", @[@"GB", @"GG", @"IM", @"JE"], @"44", @[@"DK"], @"45", @[@"SE"], @"46", @[@"NO", @"SJ"], @"47", @[@"PL"], @"48", @[@"DE"], @"49",
+ @[@"PE"], @"51", @[@"MX"], @"52", @[@"CU"], @"53", @[@"AR"], @"54", @[@"BR"], @"55", @[@"CL"], @"56", @[@"CO"], @"57", @[@"VE"], @"58",
+ @[@"MY"], @"60", @[@"AU", @"CC", @"CX"], @"61", @[@"ID"], @"62", @[@"PH"], @"63", @[@"NZ"], @"64", @[@"SG"], @"65", @[@"TH"], @"66",
+ @[@"JP"], @"81", @[@"KR"], @"82", @[@"VN"], @"84", @[@"CN"], @"86",
+ @[@"TR"], @"90", @[@"IN"], @"91", @[@"PK"], @"92", @[@"AF"], @"93", @[@"LK"], @"94", @[@"MM"], @"95", @[@"IR"], @"98",
+ @[@"SS"], @"211", @[@"MA", @"EH"], @"212", @[@"DZ"], @"213", @[@"TN"], @"216", @[@"LY"], @"218",
+ @[@"GM"], @"220", @[@"SN"], @"221", @[@"MR"], @"222", @[@"ML"], @"223", @[@"GN"], @"224", @[@"CI"], @"225", @[@"BF"], @"226", @[@"NE"], @"227", @[@"TG"], @"228", @[@"BJ"], @"229",
+ @[@"MU"], @"230", @[@"LR"], @"231", @[@"SL"], @"232", @[@"GH"], @"233", @[@"NG"], @"234", @[@"TD"], @"235", @[@"CF"], @"236", @[@"CM"], @"237", @[@"CV"], @"238", @[@"ST"], @"239",
+ @[@"GQ"], @"240", @[@"GA"], @"241", @[@"CG"], @"242", @[@"CD"], @"243", @[@"AO"], @"244", @[@"GW"], @"245", @[@"IO"], @"246", @[@"AC"], @"247", @[@"SC"], @"248", @[@"SD"], @"249",
+ @[@"RW"], @"250", @[@"ET"], @"251", @[@"SO"], @"252", @[@"DJ"], @"253", @[@"KE"], @"254", @[@"TZ"], @"255", @[@"UG"], @"256", @[@"BI"], @"257", @[@"MZ"], @"258",
+ @[@"ZM"], @"260", @[@"MG"], @"261", @[@"RE", @"YT"], @"262", @[@"ZW"], @"263", @[@"NA"], @"264", @[@"MW"], @"265", @[@"LS"], @"266", @[@"BW"], @"267", @[@"SZ"], @"268", @[@"KM"], @"269",
+ @[@"SH"], @"290", @[@"ER"], @"291", @[@"AW"], @"297", @[@"FO"], @"298", @[@"GL"], @"299",
+ @[@"GI"], @"350", @[@"PT"], @"351", @[@"LU"], @"352", @[@"IE"], @"353", @[@"IS"], @"354", @[@"AL"], @"355", @[@"MT"], @"356", @[@"CY"], @"357", @[@"FI", @"AX"], @"358", @[@"BG"], @"359",
+ @[@"LT"], @"370", @[@"LV"], @"371", @[@"EE"], @"372", @[@"MD"], @"373", @[@"AM"], @"374", @[@"BY"], @"375", @[@"AD"], @"376", @[@"MC"], @"377", @[@"SM"], @"378", @[@"VA"], @"379",
+ @[@"UA"], @"380", @[@"RS"], @"381", @[@"ME"], @"382", @[@"HR"], @"385", @[@"SI"], @"386", @[@"BA"], @"387", @[@"MK"], @"389",
+ @[@"CZ"], @"420", @[@"SK"], @"421", @[@"LI"], @"423",
+ @[@"FK"], @"500", @[@"BZ"], @"501", @[@"GT"], @"502", @[@"SV"], @"503", @[@"HN"], @"504", @[@"NI"], @"505", @[@"CR"], @"506", @[@"PA"], @"507", @[@"PM"], @"508", @[@"HT"], @"509",
+ @[@"GP", @"BL", @"MF"], @"590", @[@"BO"], @"591", @[@"GY"], @"592", @[@"EC"], @"593", @[@"GF"], @"594", @[@"PY"], @"595", @[@"MQ"], @"596", @[@"SR"], @"597", @[@"UY"], @"598", @[@"CW", @"BQ"], @"599",
+ @[@"TL"], @"670", @[@"NF"], @"672", @[@"BN"], @"673", @[@"NR"], @"674", @[@"PG"], @"675", @[@"TO"], @"676", @[@"SB"], @"677", @[@"VU"], @"678", @[@"FJ"], @"679",
+ @[@"PW"], @"680", @[@"WF"], @"681", @[@"CK"], @"682", @[@"NU"], @"683", @[@"WS"], @"685", @[@"KI"], @"686", @[@"NC"], @"687", @[@"TV"], @"688", @[@"PF"], @"689",
+ @[@"TK"], @"690", @[@"FM"], @"691", @[@"MH"], @"692",
+ @[@"001"], @"800", @[@"001"], @"808",
+ @[@"KP"], @"850", @[@"HK"], @"852", @[@"MO"], @"853", @[@"KH"], @"855", @[@"LA"], @"856",
+ @[@"001"], @"870", @[@"001"], @"878",
+ @[@"BD"], @"880", @[@"001"], @"881", @[@"001"], @"882", @[@"001"], @"883", @[@"TW"], @"886", @[@"001"], @"888",
+ @[@"MV"], @"960", @[@"LB"], @"961", @[@"JO"], @"962", @[@"SY"], @"963", @[@"IQ"], @"964", @[@"KW"], @"965", @[@"SA"], @"966", @[@"YE"], @"967", @[@"OM"], @"968",
+ @[@"PS"], @"970", @[@"AE"], @"971", @[@"IL"], @"972", @[@"BH"], @"973", @[@"QA"], @"974", @[@"BT"], @"975", @[@"MN"], @"976", @[@"NP"], @"977", @[@"001"], @"979",
+ @[@"TJ"], @"992", @[@"TM"], @"993", @[@"AZ"], @"994", @[@"GE"], @"995", @[@"KG"], @"996", @[@"UZ"], @"998", nil];
+ }
+ */
+
+
+#pragma mark - Metadata manager (phonenumberutil.js) functions -
+/**
+ * Attempts to extract a possible number from the string passed in. This
+ * currently strips all 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 {string} number the string that might contain a phone number.
+ * @return {string} the number, stripped of any non-phone-number prefix (such as
+ * 'Tel:') or an empty string if no character used to start phone numbers
+ * (such as + or any digit) is found in the number.
+ */
+- (NSString*)extractPossibleNumber:(NSString*)number
+{
+ NSString *possibleNumber = @"";
+ NSInteger start = [self stringPositionByRegex:number regex:self.VALID_START_CHAR_PATTERN_];
+
+ if (start >= 0)
+ {
+ possibleNumber = [number substringFromIndex:start];
+ // Remove trailing non-alpha non-numerical characters.
+ possibleNumber = [self replaceStringByRegex:possibleNumber regex:self.UNWANTED_END_CHAR_PATTERN_ withTemplate:@""];
+
+ // Check for extra numbers at the end.
+ NSInteger secondNumberStart = [self stringPositionByRegex:number regex:self.SECOND_NUMBER_START_PATTERN_];
+ if (secondNumberStart >= 0)
+ {
+ possibleNumber = [possibleNumber substringWithRange:NSMakeRange(0, secondNumberStart - 1)];
+ }
+ }
+ else
+ {
+ possibleNumber = @"";
+ }
+
+ return possibleNumber;
+
+ /*
+ NSString *possibleNumber = @"";
+ NSRegularExpression *currentPattern = self.VALID_START_CHAR_PATTERN_;
+ int sourceLength = phoneNumber.length;
+
+ NSArray *matches = [currentPattern matchesInString:phoneNumber options:0 range:NSMakeRange(0, sourceLength)];
+ if (matches && [matches count] > 0)
+ {
+ NSRange rangeOfFirstMatch = ((NSTextCheckingResult*)[matches objectAtIndex:0]).range;
+ possibleNumber = [phoneNumber substringFromIndex:rangeOfFirstMatch.location];
+
+ // Remove trailing non-alpha non-numerical characters.
+ currentPattern = self.UNWANTED_END_CHAR_PATTERN_;
+ possibleNumber = [currentPattern stringByReplacingMatchesInString:possibleNumber options:0
+ range:NSMakeRange(0, [possibleNumber length]) withTemplate:@""];
+ // Check for extra numbers at the end.
+ currentPattern = self.SECOND_NUMBER_START_PATTERN_;
+ matches = [currentPattern matchesInString:possibleNumber options:0
+ range:NSMakeRange(0, [possibleNumber length])];
+ if (matches && [matches count] > 0)
+ {
+ NSRange rangeOfSecondMatch = ((NSTextCheckingResult*)[matches objectAtIndex:0]).range;
+ possibleNumber = [possibleNumber substringWithRange:NSMakeRange(0, rangeOfSecondMatch.location)];
+ }
+ }
+
+ return possibleNumber;
+ */
+}
+
+
+/**
+ * Checks to see if the string of characters could possibly be a phone number at
+ * all. At the moment, checks to see that the string begins with at least 2
+ * digits, ignoring any punctuation commonly found in phone numbers. This method
+ * does not require the number to be normalized in advance - but does assume
+ * that leading non-number symbols have been removed, such as by the method
+ * extractPossibleNumber.
+ *
+ * @param {string} number string to be checked for viability as a phone number.
+ * @return {boolean} NO if the number could be a phone number of some sort,
+ * otherwise NO.
+ */
+- (BOOL)isViablePhoneNumber:(NSString*)phoneNumber
+{
+ if (phoneNumber.length < MIN_LENGTH_FOR_NSN_)
+ {
+ return NO;
+ }
+
+ return [self matchesEntirely:self.VALID_PHONE_NUMBER_PATTERN_ string:phoneNumber];
+}
+
+
+/**
+ * Normalizes a string of characters representing a phone number. This performs
+ * the following conversions:
+ * Punctuation is stripped.
+ * For ALPHA/VANITY numbers:
+ * Letters are converted to their numeric representation on a telephone
+ * keypad. The keypad used here is the one defined in ITU Recommendation
+ * E.161. This is only done if there are 3 or more letters in the number,
+ * to lessen the risk that such letters are typos.
+ * For other numbers:
+ * Wide-ascii digits are converted to normal ASCII (European) digits.
+ * Arabic-Indic numerals are converted to European numerals.
+ * Spurious alpha characters are stripped.
+ *
+ * @param {string} number a string of characters representing a phone number.
+ * @return {string} the normalized string version of the phone number.
+ */
+- (NSString*)normalizePhoneNumber:(NSString*)number
+{
+ if ([self matchesEntirely:VALID_ALPHA_PHONE_PATTERN_STRING string:number])
+ {
+ return [self normalizeHelper:number normalizationReplacements:self.ALL_NORMALIZATION_MAPPINGS_ removeNonMatches:true];
+ }
+ else
+ {
+ return [self normalizeDigitsOnly:number];
+ }
+
+ return nil;
+}
+
+
+/**
+ * Normalizes a string of characters representing a phone number. This is a
+ * wrapper for normalize(String number) but does in-place normalization of the
+ * StringBuffer provided.
+ *
+ * @param {!goog.string.StringBuffer} number a StringBuffer of characters
+ * representing a phone number that will be normalized in place.
+ * @private
+ */
+
+- (void)normalizeSB:(NSString**)number
+{
+ if (number == NULL)
+ {
+ return;
+ }
+
+ (*number) = [self normalizePhoneNumber:(*number)];
+}
+
+
+/**
+ * Normalizes a string of characters representing a phone number. This converts
+ * wide-ascii and arabic-indic numerals to European numerals, and strips
+ * punctuation and alpha characters.
+ *
+ * @param {string} number a string of characters representing a phone number.
+ * @return {string} the normalized string version of the phone number.
+ */
+- (NSString*)normalizeDigitsOnly:(NSString*)number
+{
+ return [self stringByReplacingOccurrencesString:number
+ withMap:self.DIGIT_MAPPINGS removeNonMatches:YES];
+}
+
+
+/**
+ * Converts all alpha characters in a number to their respective digits on a
+ * keypad, but retains existing formatting. Also converts wide-ascii digits to
+ * normal ascii digits, and converts Arabic-Indic numerals to European numerals.
+ *
+ * @param {string} number a string of characters representing a phone number.
+ * @return {string} the normalized string version of the phone number.
+ */
+- (NSString*)convertAlphaCharactersInNumber:(NSString*)number
+{
+ return [self stringByReplacingOccurrencesString:number
+ withMap:self.ALL_NORMALIZATION_MAPPINGS_ removeNonMatches:NO];
+}
+
+
+/**
+ * Gets the length of the geographical area code from the
+ * {@code national_number} field of the PhoneNumber object passed in, so that
+ * clients could use it to split a national significant number into geographical
+ * area code and subscriber number. It works in such a way that the resultant
+ * subscriber number should be diallable, at least on some devices. An example
+ * of how this could be used:
+ *
+ * <pre>
+ * var phoneUtil = getInstance();
+ * var number = phoneUtil.parse('16502530000', 'US');
+ * var nationalSignificantNumber =
+ * phoneUtil.getNationalSignificantNumber(number);
+ * var areaCode;
+ * var subscriberNumber;
+ *
+ * var areaCodeLength = phoneUtil.getLengthOfGeographicalAreaCode(number);
+ * if (areaCodeLength > 0) {
+ * areaCode = nationalSignificantNumber.substring(0, areaCodeLength);
+ * subscriberNumber = nationalSignificantNumber.substring(areaCodeLength);
+ * } else {
+ * areaCode = '';
+ * subscriberNumber = nationalSignificantNumber;
+ * }
+ * </pre>
+ *
+ * N.B.: area code is a very ambiguous concept, so the I18N team generally
+ * recommends against using it for most purposes, but recommends using the more
+ * general {@code national_number} instead. Read the following carefully before
+ * deciding to use this method:
+ * <ul>
+ * <li> geographical area codes change over time, and this method honors those
+ * changes; therefore, it doesn't guarantee the stability of the result it
+ * produces.
+ * <li> subscriber numbers may not be diallable from all devices (notably
+ * mobile devices, which typically requires the full national_number to be
+ * dialled in most regions).
+ * <li> most non-geographical numbers have no area codes, including numbers
+ * from non-geographical entities.
+ * <li> some geographical numbers have no area codes.
+ * </ul>
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the PhoneNumber object for
+ * which clients want to know the length of the area code.
+ * @return {number} the length of area code of the PhoneNumber object passed in.
+ */
+- (NSUInteger)getLengthOfGeographicalAreaCode:(NBPhoneNumber*)phoneNumber error:(NSError **)error
+{
+ NSUInteger res = 0;
+ @try {
+ res = [self getLengthOfGeographicalAreaCode:phoneNumber];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ {
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ }
+ return res;
+}
+
+
+- (NSUInteger)getLengthOfGeographicalAreaCode:(NBPhoneNumber*)phoneNumber
+{
+ NSString *regionCode = [self getRegionCodeForNumber:phoneNumber];
+ NBPhoneMetaData *metadata = [self getMetadataForRegion:regionCode];
+
+ if (metadata == nil)
+ {
+ return 0;
+ }
+ // If a country doesn't use a national prefix, and this number doesn't have
+ // an Italian leading zero, we assume it is a closed dialling plan with no
+ // area codes.
+ if (metadata.nationalPrefix == nil && phoneNumber.italianLeadingZero == NO)
+ {
+ return 0;
+ }
+
+ if ([self isNumberGeographical:phoneNumber] == NO)
+ {
+ return 0;
+ }
+
+ return [self getLengthOfNationalDestinationCode:phoneNumber];
+}
+
+
+/**
+ * Gets the length of the national destination code (NDC) from the PhoneNumber
+ * object passed in, so that clients could use it to split a national
+ * significant number into NDC and subscriber number. The NDC of a phone number
+ * is normally the first group of digit(s) right after the country calling code
+ * when the number is formatted in the international format, if there is a
+ * subscriber number part that follows. An example of how this could be used:
+ *
+ * <pre>
+ * var phoneUtil = getInstance();
+ * var number = phoneUtil.parse('18002530000', 'US');
+ * var nationalSignificantNumber =
+ * phoneUtil.getNationalSignificantNumber(number);
+ * var nationalDestinationCode;
+ * var subscriberNumber;
+ *
+ * var nationalDestinationCodeLength =
+ * phoneUtil.getLengthOfNationalDestinationCode(number);
+ * if (nationalDestinationCodeLength > 0) {
+ * nationalDestinationCode =
+ * nationalSignificantNumber.substring(0, nationalDestinationCodeLength);
+ * subscriberNumber =
+ * nationalSignificantNumber.substring(nationalDestinationCodeLength);
+ * } else {
+ * nationalDestinationCode = '';
+ * subscriberNumber = nationalSignificantNumber;
+ * }
+ * </pre>
+ *
+ * Refer to the unittests to see the difference between this function and
+ * {@link #getLengthOfGeographicalAreaCode}.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the PhoneNumber object for
+ * which clients want to know the length of the NDC.
+ * @return {number} the length of NDC of the PhoneNumber object passed in.
+ */
+- (NSUInteger)getLengthOfNationalDestinationCode:(NBPhoneNumber*)phoneNumber error:(NSError **)error
+{
+ NSUInteger res = 0;
+
+ @try {
+ res = [self getLengthOfNationalDestinationCode:phoneNumber];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ {
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ }
+
+ return res;
+}
+
+
+- (NSUInteger)getLengthOfNationalDestinationCode:(NBPhoneNumber*)phoneNumber
+{
+ NBPhoneNumber *copiedProto = nil;
+ if ([self hasValue:phoneNumber.extension])
+ {
+ copiedProto = [phoneNumber copy];
+ copiedProto.extension = nil;
+ }
+ else
+ {
+ copiedProto = phoneNumber;
+ }
+
+ NSString *nationalSignificantNumber = [self format:copiedProto numberFormat:NBEPhoneNumberFormatINTERNATIONAL];
+ NSMutableArray *numberGroups = [[self componentsSeparatedByRegex:nationalSignificantNumber regex:NON_DIGITS_PATTERN_] mutableCopy];
+
+ // The pattern will start with '+COUNTRY_CODE ' so the first group will always
+ // be the empty string (before the + symbol) and the second group will be the
+ // country calling code. The third group will be area code if it is not the
+ // last group.
+ // NOTE: On IE the first group that is supposed to be the empty string does
+ // not appear in the array of number groups... so make the result on non-IE
+ // browsers to be that of IE.
+ if ([numberGroups count] > 0 && ((NSString*)[numberGroups objectAtIndex:0]).length <= 0)
+ {
+ [numberGroups removeObjectAtIndex:0];
+ }
+
+ if ([numberGroups count] <= 2)
+ {
+ return 0;
+ }
+
+ NSArray *regionCodes = [self regionCodeFromCountryCode:phoneNumber.countryCode];
+ BOOL isExists = NO;
+
+ for (NSString *regCode in regionCodes)
+ {
+ if ([regCode isEqualToString:@"AR"])
+ {
+ isExists = YES;
+ break;
+ }
+ }
+
+ if (isExists && [self getNumberType:phoneNumber] == NBEPhoneNumberTypeMOBILE)
+ {
+ // Argentinian mobile numbers, when formatted in the international format,
+ // are in the form of +54 9 NDC XXXX.... As a result, we take the length of
+ // the third group (NDC) and add 1 for the digit 9, which also forms part of
+ // the national significant number.
+ //
+ // TODO: Investigate the possibility of better modeling the metadata to make
+ // it easier to obtain the NDC.
+ return ((NSString*)[numberGroups objectAtIndex:2]).length + 1;
+ }
+
+ return ((NSString*)[numberGroups objectAtIndex:1]).length;
+}
+
+
+/**
+ * Normalizes a string of characters representing a phone number by replacing
+ * all characters found in the accompanying map with the values therein, and
+ * stripping all other characters if removeNonMatches is NO.
+ *
+ * @param {string} number a string of characters representing a phone number.
+ * @param {!Object.<string, string>} normalizationReplacements a mapping of
+ * characters to what they should be replaced by in the normalized version
+ * of the phone number.
+ * @param {boolean} removeNonMatches indicates whether characters that are not
+ * able to be replaced should be stripped from the number. If this is NO,
+ * they will be left unchanged in the number.
+ * @return {string} the normalized string version of the phone number.
+ * @private
+ */
+- (NSString*)normalizeHelper:(NSString*)sourceString normalizationReplacements:(NSDictionary*)normalizationReplacements
+ removeNonMatches:(BOOL)removeNonMatches
+{
+ NSMutableString *normalizedNumber = [[NSMutableString alloc] init];
+ unichar character = 0;
+ NSString *newDigit = @"";
+ NSUInteger numberLength = sourceString.length;
+
+ for (NSUInteger i = 0; i<numberLength; ++i)
+ {
+ character = [sourceString characterAtIndex:i];
+ newDigit = [normalizationReplacements objectForKey:[[NSString stringWithFormat: @"%C", character] uppercaseString]];
+ if (newDigit != nil)
+ {
+ [normalizedNumber appendString:newDigit];
+ }
+ else if (removeNonMatches == NO)
+ {
+ [normalizedNumber appendString:[NSString stringWithFormat: @"%C", character]];
+ }
+ // If neither of the above are NO, we remove this character.
+
+ //NSLog(@"[%@]", normalizedNumber);
+ }
+
+ return normalizedNumber;
+}
+
+
+/**
+ * Helper function to check if the national prefix formatting rule has the first
+ * group only, i.e., does not start with the national prefix.
+ *
+ * @param {string} nationalPrefixFormattingRule The formatting rule for the
+ * national prefix.
+ * @return {boolean} NO if the national prefix formatting rule has the first
+ * group only.
+ */
+- (BOOL)formattingRuleHasFirstGroupOnly:(NSString*)nationalPrefixFormattingRule
+{
+ BOOL hasFound = NO;
+ if ([self stringPositionByRegex:nationalPrefixFormattingRule regex:FIRST_GROUP_ONLY_PREFIX_PATTERN_] >= 0)
+ {
+ hasFound = YES;
+ }
+
+ return (([nationalPrefixFormattingRule length] == 0) || hasFound);
+}
+
+
+/**
+ * Tests whether a phone number has a geographical association. It checks if
+ * the number is associated to a certain region in the country where it belongs
+ * to. Note that this doesn't verify if the number is actually in use.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} phoneNumber The phone number to test.
+ * @return {boolean} NO if the phone number has a geographical association.
+ * @private
+ */
+- (BOOL)isNumberGeographical:(NBPhoneNumber*)phoneNumber
+{
+ NBEPhoneNumberType numberType = [self getNumberType:phoneNumber];
+ // TODO: Include mobile phone numbers from countries like Indonesia, which
+ // has some mobile numbers that are geographical.
+ return numberType == NBEPhoneNumberTypeFIXED_LINE || numberType == NBEPhoneNumberTypeFIXED_LINE_OR_MOBILE;
+}
+
+
+/**
+ * Helper function to check region code is not unknown or nil.
+ *
+ * @param {?string} regionCode the ISO 3166-1 two-letter region code.
+ * @return {boolean} NO if region code is valid.
+ * @private
+ */
+- (BOOL)isValidRegionCode:(NSString*)regionCode
+{
+ // In Java we check whether the regionCode is contained in supportedRegions
+ // that is built out of all the values of countryCallingCodeToRegionCodeMap
+ // (countryCodeToRegionCodeMap in JS) minus REGION_CODE_FOR_NON_GEO_ENTITY.
+ // In JS we check whether the regionCode is contained in the keys of
+ // countryToMetadata but since for non-geographical country calling codes
+ // (e.g. +800) we use the country calling codes instead of the region code as
+ // key in the map we have to make sure regionCode is not a number to prevent
+ // returning NO for non-geographical country calling codes.
+ return [self hasValue:regionCode] && [self isNaN:regionCode] && [self getMetadataForRegion:regionCode.uppercaseString] != nil;
+}
+
+
+/**
+ * Helper function to check the country calling code is valid.
+ *
+ * @param {number} countryCallingCode the country calling code.
+ * @return {boolean} NO if country calling code code is valid.
+ * @private
+ */
+- (BOOL)hasValidCountryCallingCode:(NSNumber *)countryCallingCode
+{
+ id res = [self regionCodeFromCountryCode:countryCallingCode];
+ if (res != nil)
+ {
+ return YES;
+ }
+
+ return NO;
+}
+
+
+/**
+ * Formats a phone number in the specified format using default rules. Note that
+ * this does not promise to produce a phone number that the user can dial from
+ * where they are - although we do format in either 'national' or
+ * 'international' format depending on what the client asks for, we do not
+ * currently support a more abbreviated format, such as for users in the same
+ * 'area' who could potentially dial the number without area code. Note that if
+ * the phone number has a country calling code of 0 or an otherwise invalid
+ * country calling code, we cannot work out which formatting rules to apply so
+ * we return the national significant number with no formatting applied.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number to be
+ * formatted.
+ * @param {i18n.phonenumbers.PhoneNumberFormat} numberFormat the format the
+ * phone number should be formatted into.
+ * @return {string} the formatted phone number.
+ */
+- (NSString*)format:(NBPhoneNumber*)phoneNumber numberFormat:(NBEPhoneNumberFormat)numberFormat error:(NSError**)error;
+{
+ NSString *res = nil;
+ @try {
+ res = [self format:phoneNumber numberFormat:numberFormat];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+- (NSString*)format:(NBPhoneNumber*)phoneNumber numberFormat:(NBEPhoneNumberFormat)numberFormat
+{
+ if ([phoneNumber.nationalNumber isEqualToNumber:@0] && [self hasValue:phoneNumber.rawInput])
+ {
+ // Unparseable numbers that kept their raw input just use that.
+ // This is the only case where a number can be formatted as E164 without a
+ // leading '+' symbol (but the original number wasn't parseable anyway).
+ // TODO: Consider removing the 'if' above so that unparseable strings
+ // without raw input format to the empty string instead of "+00"
+ /** @type {string} */
+ NSString *rawInput = phoneNumber.rawInput;
+ if ([self hasValue:rawInput]) {
+ return rawInput;
+ }
+ }
+
+ NSNumber *countryCallingCode = phoneNumber.countryCode;
+ NSString *nationalSignificantNumber = [self getNationalSignificantNumber:phoneNumber];
+
+ if (numberFormat == NBEPhoneNumberFormatE164)
+ {
+ // Early exit for E164 case (even if the country calling code is invalid)
+ // since no formatting of the national number needs to be applied.
+ // Extensions are not formatted.
+ return [self prefixNumberWithCountryCallingCode:countryCallingCode phoneNumberFormat:NBEPhoneNumberFormatE164
+ formattedNationalNumber:nationalSignificantNumber formattedExtension:@""];
+ }
+
+ if ([self hasValidCountryCallingCode:countryCallingCode] == NO)
+ {
+ return nationalSignificantNumber;
+ }
+
+ // Note getRegionCodeForCountryCode() is used because formatting information
+ // for regions which share a country calling code is contained by only one
+ // region for performance reasons. For example, for NANPA regions it will be
+ // contained in the metadata for US.
+ NSArray *regionCodeArray = [self regionCodeFromCountryCode:countryCallingCode];
+ NSString *regionCode = [regionCodeArray objectAtIndex:0];
+
+ // Metadata cannot be nil because the country calling code is valid (which
+ // means that the region code cannot be ZZ and must be one of our supported
+ // region codes).
+ NBPhoneMetaData *metadata = [self getMetadataForRegionOrCallingCode:countryCallingCode regionCode:regionCode];
+ NSString *formattedExtension = [self maybeGetFormattedExtension:phoneNumber metadata:metadata numberFormat:numberFormat];
+ NSString *formattedNationalNumber = [self formatNsn:nationalSignificantNumber metadata:metadata phoneNumberFormat:numberFormat carrierCode:nil];
+
+ return [self prefixNumberWithCountryCallingCode:countryCallingCode phoneNumberFormat:numberFormat
+ formattedNationalNumber:formattedNationalNumber formattedExtension:formattedExtension];
+}
+
+
+/**
+ * Formats a phone number in the specified format using client-defined
+ * formatting rules. Note that if the phone number has a country calling code of
+ * zero or an otherwise invalid country calling code, we cannot work out things
+ * like whether there should be a national prefix applied, or how to format
+ * extensions, so we return the national significant number with no formatting
+ * applied.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number to be
+ * formatted.
+ * @param {i18n.phonenumbers.PhoneNumberFormat} numberFormat the format the
+ * phone number should be formatted into.
+ * @param {Array.<i18n.phonenumbers.NumberFormat>} userDefinedFormats formatting
+ * rules specified by clients.
+ * @return {string} the formatted phone number.
+ */
+- (NSString*)formatByPattern:(NBPhoneNumber*)number numberFormat:(NBEPhoneNumberFormat)numberFormat userDefinedFormats:(NSArray*)userDefinedFormats error:(NSError**)error
+{
+ NSString *res = nil;
+ @try {
+ res = [self formatByPattern:number numberFormat:numberFormat userDefinedFormats:userDefinedFormats];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (NSString*)formatByPattern:(NBPhoneNumber*)number numberFormat:(NBEPhoneNumberFormat)numberFormat userDefinedFormats:(NSArray*)userDefinedFormats
+{
+ NSNumber *countryCallingCode = number.countryCode;
+ NSString *nationalSignificantNumber = [self getNationalSignificantNumber:number];
+
+ if ([self hasValidCountryCallingCode:countryCallingCode] == NO)
+ {
+ return nationalSignificantNumber;
+ }
+
+ // Note getRegionCodeForCountryCode() is used because formatting information
+ // for regions which share a country calling code is contained by only one
+ // region for performance reasons. For example, for NANPA regions it will be
+ // contained in the metadata for US.
+ NSArray *regionCodes = [self regionCodeFromCountryCode:countryCallingCode];
+ NSString *regionCode = nil;
+ if (regionCodes != nil && regionCodes.count > 0)
+ {
+ regionCode = [regionCodes objectAtIndex:0];
+ }
+
+ // Metadata cannot be nil because the country calling code is valid
+ /** @type {i18n.phonenumbers.PhoneMetadata} */
+ NBPhoneMetaData *metadata = [self getMetadataForRegionOrCallingCode:countryCallingCode regionCode:regionCode];
+
+ NSString *formattedNumber = @"";
+ NBNumberFormat *formattingPattern = [self chooseFormattingPatternForNumber:userDefinedFormats nationalNumber:nationalSignificantNumber];
+ if (formattingPattern == nil)
+ {
+ // If no pattern above is matched, we format the number as a whole.
+ formattedNumber = nationalSignificantNumber;
+ }
+ else
+ {
+ // Before we do a replacement of the national prefix pattern $NP with the
+ // national prefix, we need to copy the rule so that subsequent replacements
+ // for different numbers have the appropriate national prefix.
+ NBNumberFormat *numFormatCopy = [formattingPattern copy];
+ NSString *nationalPrefixFormattingRule = formattingPattern.nationalPrefixFormattingRule;
+
+ if (nationalPrefixFormattingRule.length > 0)
+ {
+ NSString *nationalPrefix = metadata.nationalPrefix;
+ if (nationalPrefix.length > 0)
+ {
+ // Replace $NP with national prefix and $FG with the first group ($1).
+ nationalPrefixFormattingRule = [self replaceStringByRegex:nationalPrefixFormattingRule regex:NP_PATTERN_ withTemplate:nationalPrefix];
+ nationalPrefixFormattingRule = [self replaceStringByRegex:nationalPrefixFormattingRule regex:FG_PATTERN_ withTemplate:@"\\$1"];
+ numFormatCopy.nationalPrefixFormattingRule = nationalPrefixFormattingRule;
+ }
+ else
+ {
+ // We don't want to have a rule for how to format the national prefix if
+ // there isn't one.
+ numFormatCopy.nationalPrefixFormattingRule = @"";
+ }
+ }
+
+ formattedNumber = [self formatNsnUsingPattern:nationalSignificantNumber
+ formattingPattern:numFormatCopy numberFormat:numberFormat carrierCode:nil];
+ }
+
+ NSString *formattedExtension = [self maybeGetFormattedExtension:number metadata:metadata numberFormat:numberFormat];
+
+ //NSLog(@"!@# prefixNumberWithCountryCallingCode called [%@]", formattedExtension);
+ return [self prefixNumberWithCountryCallingCode:countryCallingCode
+ phoneNumberFormat:numberFormat
+ formattedNationalNumber:formattedNumber
+ formattedExtension:formattedExtension];
+}
+
+
+/**
+ * Formats a phone number in national format for dialing using the carrier as
+ * specified in the {@code carrierCode}. The {@code carrierCode} will always be
+ * used regardless of whether the phone number already has a preferred domestic
+ * carrier code stored. If {@code carrierCode} contains an empty string, returns
+ * the number in national format without any carrier code.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number to be
+ * formatted.
+ * @param {string} carrierCode the carrier selection code to be used.
+ * @return {string} the formatted phone number in national format for dialing
+ * using the carrier as specified in the {@code carrierCode}.
+ */
+- (NSString*)formatNationalNumberWithCarrierCode:(NBPhoneNumber*)number carrierCode:(NSString*)carrierCode error:(NSError **)error
+{
+ NSString *res = nil;
+ @try {
+ res = [self formatNationalNumberWithCarrierCode:number carrierCode:carrierCode];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (NSString*)formatNationalNumberWithCarrierCode:(NBPhoneNumber*)number carrierCode:(NSString*)carrierCode
+{
+ NSNumber *countryCallingCode = number.countryCode;
+ NSString *nationalSignificantNumber = [self getNationalSignificantNumber:number];
+ if ([self hasValidCountryCallingCode:countryCallingCode] == NO)
+ {
+ return nationalSignificantNumber;
+ }
+
+ // Note getRegionCodeForCountryCode() is used because formatting information
+ // for regions which share a country calling code is contained by only one
+ // region for performance reasons. For example, for NANPA regions it will be
+ // contained in the metadata for US.
+ NSString *regionCode = [self getRegionCodeForCountryCode:countryCallingCode];
+ // Metadata cannot be nil because the country calling code is valid.
+ NBPhoneMetaData *metadata = [self getMetadataForRegionOrCallingCode:countryCallingCode regionCode:regionCode];
+ NSString *formattedExtension = [self maybeGetFormattedExtension:number metadata:metadata numberFormat:NBEPhoneNumberFormatNATIONAL];
+ NSString *formattedNationalNumber = [self formatNsn:nationalSignificantNumber metadata:metadata phoneNumberFormat:NBEPhoneNumberFormatNATIONAL carrierCode:carrierCode];
+ return [self prefixNumberWithCountryCallingCode:countryCallingCode phoneNumberFormat:NBEPhoneNumberFormatNATIONAL formattedNationalNumber:formattedNationalNumber formattedExtension:formattedExtension];
+}
+
+
+/**
+ * @param {number} countryCallingCode
+ * @param {?string} regionCode
+ * @return {i18n.phonenumbers.PhoneMetadata}
+ * @private
+ */
+- (NBPhoneMetaData*)getMetadataForRegionOrCallingCode:(NSNumber*)countryCallingCode regionCode:(NSString*)regionCode
+{
+ return [_REGION_CODE_FOR_NON_GEO_ENTITY isEqualToString:regionCode] ?
+ [self getMetadataForNonGeographicalRegion:countryCallingCode] : [self getMetadataForRegion:regionCode];
+}
+
+
+/**
+ * Formats a phone number in national format for dialing using the carrier as
+ * specified in the preferred_domestic_carrier_code field of the PhoneNumber
+ * object passed in. If that is missing, use the {@code fallbackCarrierCode}
+ * passed in instead. If there is no {@code preferred_domestic_carrier_code},
+ * and the {@code fallbackCarrierCode} contains an empty string, return the
+ * number in national format without any carrier code.
+ *
+ * <p>Use {@link #formatNationalNumberWithCarrierCode} instead if the carrier
+ * code passed in should take precedence over the number's
+ * {@code preferred_domestic_carrier_code} when formatting.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number to be
+ * formatted.
+ * @param {string} fallbackCarrierCode the carrier selection code to be used, if
+ * none is found in the phone number itself.
+ * @return {string} the formatted phone number in national format for dialing
+ * using the number's preferred_domestic_carrier_code, or the
+ * {@code fallbackCarrierCode} passed in if none is found.
+ */
+- (NSString*)formatNationalNumberWithPreferredCarrierCode:(NBPhoneNumber*)number
+ fallbackCarrierCode:(NSString*)fallbackCarrierCode error:(NSError **)error
+{
+ NSString *res = nil;
+ @try {
+ res = [self formatNationalNumberWithCarrierCode:number carrierCode:fallbackCarrierCode];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+
+ return res;
+}
+
+
+- (NSString*)formatNationalNumberWithPreferredCarrierCode:(NBPhoneNumber*)number fallbackCarrierCode:(NSString*)fallbackCarrierCode
+{
+ NSString *domesticCarrierCode = number.preferredDomesticCarrierCode != nil ? number.preferredDomesticCarrierCode : fallbackCarrierCode;
+ return [self formatNationalNumberWithCarrierCode:number carrierCode:domesticCarrierCode];
+}
+
+
+/**
+ * Returns a number formatted in such a way that it can be dialed from a mobile
+ * phone in a specific region. If the number cannot be reached from the region
+ * (e.g. some countries block toll-free numbers from being called outside of the
+ * country), the method returns an empty string.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number to be
+ * formatted.
+ * @param {string} regionCallingFrom the region where the call is being placed.
+ * @param {boolean} withFormatting whether the number should be returned with
+ * formatting symbols, such as spaces and dashes.
+ * @return {string} the formatted phone number.
+ */
+- (NSString*)formatNumberForMobileDialing:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom withFormatting:(BOOL)withFormatting error:(NSError**)error
+{
+ NSString *res = nil;
+ @try {
+ res = [self formatNumberForMobileDialing:number regionCallingFrom:regionCallingFrom withFormatting:withFormatting];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (NSString*)formatNumberForMobileDialing:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom withFormatting:(BOOL)withFormatting
+{
+ NSNumber *countryCallingCode = number.countryCode;
+ if ([self hasValidCountryCallingCode:countryCallingCode] == NO)
+ {
+ return [self hasValue:number.rawInput] ? number.rawInput : @"";
+ }
+
+ NSString *formattedNumber = @"";
+ // Clear the extension, as that part cannot normally be dialed together with
+ // the main number.
+ NBPhoneNumber *numberNoExt = [number copy];
+ numberNoExt.extension = @"";
+
+ NSString *regionCode = [self getRegionCodeForCountryCode:countryCallingCode];
+ if ([regionCallingFrom isEqualToString:regionCode])
+ {
+ NBEPhoneNumberType numberType = [self getNumberType:numberNoExt];
+ BOOL isFixedLineOrMobile = (numberType == NBEPhoneNumberTypeFIXED_LINE) || (numberType == NBEPhoneNumberTypeMOBILE) || (numberType == NBEPhoneNumberTypeFIXED_LINE_OR_MOBILE);
+ // Carrier codes may be needed in some countries. We handle this here.
+ if ([regionCode isEqualToString:@"CO"] && numberType == NBEPhoneNumberTypeFIXED_LINE)
+ {
+ formattedNumber = [self formatNationalNumberWithCarrierCode:numberNoExt
+ carrierCode:COLOMBIA_MOBILE_TO_FIXED_LINE_PREFIX_];
+ }
+ else if ([regionCode isEqualToString:@"BR"] && isFixedLineOrMobile)
+ {
+ formattedNumber = [self hasValue:numberNoExt.preferredDomesticCarrierCode] ?
+ [self formatNationalNumberWithPreferredCarrierCode:numberNoExt fallbackCarrierCode:@""] : @"";
+ // Brazilian fixed line and mobile numbers need to be dialed with a
+ // carrier code when called within Brazil. Without that, most of the
+ // carriers won't connect the call. Because of that, we return an
+ // empty string here.
+ }
+ else
+ {
+ // For NANPA countries, non-geographical countries, and Mexican fixed
+ // line and mobile numbers, we output international format for numbersi
+ // that can be dialed internationally as that always works.
+ if (([countryCallingCode isEqualToNumber:@(NANPA_COUNTRY_CODE_)] ||
+ [regionCode isEqualToString:_REGION_CODE_FOR_NON_GEO_ENTITY] ||
+ // MX fixed line and mobile numbers should always be formatted in
+ // international format, even when dialed within MX. For national
+ // format to work, a carrier code needs to be used, and the correct
+ // carrier code depends on if the caller and callee are from the
+ // same local area. It is trickier to get that to work correctly than
+ // using international format, which is tested to work fine on all
+ // carriers.
+ ([regionCode isEqualToString:@"MX"] && isFixedLineOrMobile)) && [self canBeInternationallyDialled:numberNoExt])
+ {
+ formattedNumber = [self format:numberNoExt numberFormat:NBEPhoneNumberFormatINTERNATIONAL];
+ }
+ else
+ {
+ formattedNumber = [self format:numberNoExt numberFormat:NBEPhoneNumberFormatNATIONAL];
+ }
+ }
+ }
+ else if ([self canBeInternationallyDialled:numberNoExt])
+ {
+ return withFormatting ? [self format:numberNoExt numberFormat:NBEPhoneNumberFormatINTERNATIONAL] :
+ [self format:numberNoExt numberFormat:NBEPhoneNumberFormatE164];
+ }
+
+ return withFormatting ?
+ formattedNumber : [self normalizeHelper:formattedNumber normalizationReplacements:self.DIALLABLE_CHAR_MAPPINGS_ removeNonMatches:YES];
+}
+
+
+/**
+ * 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 that of the region where
+ * the number is from, then NATIONAL formatting will be applied.
+ *
+ * <p>If the number itself has a country calling code of zero or an otherwise
+ * invalid country calling code, then we return the number with no formatting
+ * applied.
+ *
+ * <p>Note this function takes care of the case for calling inside of NANPA and
+ * between Russia and Kazakhstan (who share the same country calling code). In
+ * those cases, no international prefix is used. For regions which have multiple
+ * international prefixes, the number in its INTERNATIONAL format will be
+ * returned instead.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number to be
+ * formatted.
+ * @param {string} regionCallingFrom the region where the call is being placed.
+ * @return {string} the formatted phone number.
+ */
+- (NSString*)formatOutOfCountryCallingNumber:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom error:(NSError**)error
+{
+ NSString *res = nil;
+ @try {
+ res = [self formatOutOfCountryCallingNumber:number regionCallingFrom:regionCallingFrom];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+
+ return res;
+}
+
+- (NSString*)formatOutOfCountryCallingNumber:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom
+{
+ if ([self isValidRegionCode:regionCallingFrom] == NO)
+ {
+ return [self format:number numberFormat:NBEPhoneNumberFormatINTERNATIONAL];
+ }
+
+ NSNumber *countryCallingCode = number.countryCode;
+ NSString *nationalSignificantNumber = [self getNationalSignificantNumber:number];
+ if ([self hasValidCountryCallingCode:countryCallingCode] == NO)
+ {
+ return nationalSignificantNumber;
+ }
+
+ if ([countryCallingCode isEqualToNumber: @(NANPA_COUNTRY_CODE_)])
+ {
+ if ([self isNANPACountry:regionCallingFrom])
+ {
+ // For NANPA regions, return the national format for these regions but
+ // prefix it with the country calling code.
+ return [NSString stringWithFormat:@"%@ %@", countryCallingCode, [self format:number numberFormat:NBEPhoneNumberFormatNATIONAL]];
+ }
+ }
+ else if ([countryCallingCode isEqualToNumber: [self getCountryCodeForValidRegion:regionCallingFrom]])
+ {
+ // If regions share a country calling code, the country calling code need
+ // not be dialled. This also applies when dialling within a region, so this
+ // if clause covers both these cases. Technically this is the case for
+ // dialling from La Reunion to other overseas departments of France (French
+ // Guiana, Martinique, Guadeloupe), but not vice versa - so we don't cover
+ // this edge case for now and for those cases return the version including
+ // country calling code. Details here:
+ // http://www.petitfute.com/voyage/225-info-pratiques-reunion
+ return [self format:number numberFormat:NBEPhoneNumberFormatNATIONAL];
+ }
+ // Metadata cannot be nil because we checked 'isValidRegionCode()' above.
+ NBPhoneMetaData *metadataForRegionCallingFrom = [self getMetadataForRegion:regionCallingFrom];
+ NSString *internationalPrefix = metadataForRegionCallingFrom.internationalPrefix;
+
+ // For regions that have multiple international prefixes, the international
+ // format of the number is returned, unless there is a preferred international
+ // prefix.
+ NSString *internationalPrefixForFormatting = @"";
+ if ([self matchesEntirely:UNIQUE_INTERNATIONAL_PREFIX_ string:internationalPrefix])
+ {
+ internationalPrefixForFormatting = internationalPrefix;
+ }
+ else if ([self hasValue:metadataForRegionCallingFrom.preferredInternationalPrefix])
+ {
+ internationalPrefixForFormatting = metadataForRegionCallingFrom.preferredInternationalPrefix;
+ }
+
+ NSString *regionCode = [self getRegionCodeForCountryCode:countryCallingCode];
+ // Metadata cannot be nil because the country calling code is valid.
+ NBPhoneMetaData *metadataForRegion = [self getMetadataForRegionOrCallingCode:countryCallingCode regionCode:regionCode];
+ NSString *formattedNationalNumber = [self formatNsn:nationalSignificantNumber metadata:metadataForRegion
+ phoneNumberFormat:NBEPhoneNumberFormatINTERNATIONAL carrierCode:nil];
+ NSString *formattedExtension = [self maybeGetFormattedExtension:number metadata:metadataForRegion numberFormat:NBEPhoneNumberFormatINTERNATIONAL];
+
+ NSString *hasLenth = [NSString stringWithFormat:@"%@ %@ %@%@", internationalPrefixForFormatting, countryCallingCode, formattedNationalNumber, formattedExtension];
+ NSString *hasNotLength = [self prefixNumberWithCountryCallingCode:countryCallingCode phoneNumberFormat:NBEPhoneNumberFormatINTERNATIONAL
+ formattedNationalNumber:formattedNationalNumber formattedExtension:formattedExtension];
+
+ return internationalPrefixForFormatting.length > 0 ? hasLenth:hasNotLength;
+}
+
+
+/**
+ * A helper function that is used by format and formatByPattern.
+ *
+ * @param {number} countryCallingCode the country calling code.
+ * @param {i18n.phonenumbers.PhoneNumberFormat} numberFormat the format the
+ * phone number should be formatted into.
+ * @param {string} formattedNationalNumber
+ * @param {string} formattedExtension
+ * @return {string} the formatted phone number.
+ * @private
+ */
+- (NSString*)prefixNumberWithCountryCallingCode:(NSNumber*)countryCallingCode phoneNumberFormat:(NBEPhoneNumberFormat)numberFormat
+ formattedNationalNumber:(NSString*)formattedNationalNumber
+ formattedExtension:(NSString*)formattedExtension
+{
+ switch (numberFormat)
+ {
+ case NBEPhoneNumberFormatE164:
+ return [NSString stringWithFormat:@"+%@%@%@", countryCallingCode, formattedNationalNumber, formattedExtension];
+ case NBEPhoneNumberFormatINTERNATIONAL:
+ return [NSString stringWithFormat:@"+%@ %@%@", countryCallingCode, formattedNationalNumber, formattedExtension];
+ case NBEPhoneNumberFormatRFC3966:
+ return [NSString stringWithFormat:@"%@+%@-%@%@", RFC3966_PREFIX_, countryCallingCode, formattedNationalNumber, formattedExtension];
+ case NBEPhoneNumberFormatNATIONAL:
+ default:
+ return [NSString stringWithFormat:@"%@%@", formattedNationalNumber, formattedExtension];
+ }
+}
+
+
+/**
+ * Formats a phone number using the original phone number format that the number
+ * is parsed from. The original format is embedded in the country_code_source
+ * field of the PhoneNumber object passed in. If such information is missing,
+ * the number will be formatted into the NATIONAL format by default. When the
+ * number contains a leading zero and this is unexpected for this country, or we
+ * don't have a formatting pattern for the number, the method returns the raw
+ * input when it is available.
+ *
+ * Note this method guarantees no digit will be inserted, removed or modified as
+ * a result of formatting.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number that needs to
+ * be formatted in its original number format.
+ * @param {string} regionCallingFrom the region whose IDD needs to be prefixed
+ * if the original number has one.
+ * @return {string} the formatted phone number in its original number format.
+ */
+- (NSString*)formatInOriginalFormat:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom error:(NSError **)error
+{
+ NSString *res = nil;
+ @try {
+ res = [self formatInOriginalFormat:number regionCallingFrom:regionCallingFrom];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+
+ return res;
+}
+
+
+- (NSString*)formatInOriginalFormat:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom
+{
+ if ([self hasValue:number.rawInput] && ([self hasUnexpectedItalianLeadingZero:number] || [self hasFormattingPatternForNumber:number] == NO))
+ {
+ // We check if we have the formatting pattern because without that, we might
+ // format the number as a group without national prefix.
+ return number.rawInput;
+ }
+
+ if (number.countryCodeSource == nil)
+ {
+ return [self format:number numberFormat:NBEPhoneNumberFormatNATIONAL];
+ }
+
+ NSString *formattedNumber = @"";
+
+ switch ([number.countryCodeSource intValue])
+ {
+ case NBECountryCodeSourceFROM_NUMBER_WITH_PLUS_SIGN:
+ formattedNumber = [self format:number numberFormat:NBEPhoneNumberFormatINTERNATIONAL];
+ break;
+ case NBECountryCodeSourceFROM_NUMBER_WITH_IDD:
+ formattedNumber = [self formatOutOfCountryCallingNumber:number regionCallingFrom:regionCallingFrom];
+ break;
+ case NBECountryCodeSourceFROM_NUMBER_WITHOUT_PLUS_SIGN:
+ formattedNumber = [[self format:number numberFormat:NBEPhoneNumberFormatINTERNATIONAL] substringFromIndex:1];
+ break;
+ case NBECountryCodeSourceFROM_DEFAULT_COUNTRY:
+ // Fall-through to default case.
+ default:
+ {
+ NSString *regionCode = [self getRegionCodeForCountryCode:number.countryCode];
+ // We strip non-digits from the NDD here, and from the raw input later,
+ // so that we can compare them easily.
+ NSString *nationalPrefix = [self getNddPrefixForRegion:regionCode stripNonDigits:YES];
+ NSString *nationalFormat = [self format:number numberFormat:NBEPhoneNumberFormatNATIONAL];
+ if (nationalPrefix == nil || nationalPrefix.length == 0)
+ {
+ // If the region doesn't have a national prefix at all, we can safely
+ // return the national format without worrying about a national prefix
+ // being added.
+ formattedNumber = nationalFormat;
+ break;
+ }
+ // Otherwise, we check if the original number was entered with a national
+ // prefix.
+ if ([self rawInputContainsNationalPrefix:number.rawInput nationalPrefix:nationalPrefix regionCode:regionCode])
+ {
+ // If so, we can safely return the national format.
+ formattedNumber = nationalFormat;
+ break;
+ }
+ // Metadata cannot be nil here because getNddPrefixForRegion() (above)
+ // returns nil if there is no metadata for the region.
+ NBPhoneMetaData *metadata = [self getMetadataForRegion:regionCode];
+ NSString *nationalNumber = [self getNationalSignificantNumber:number];
+ NBNumberFormat *formatRule = [self chooseFormattingPatternForNumber:metadata.numberFormats nationalNumber:nationalNumber];
+ // The format rule could still be nil here if the national number was 0
+ // and there was no raw input (this should not be possible for numbers
+ // generated by the phonenumber library as they would also not have a
+ // country calling code and we would have exited earlier).
+ if (formatRule == nil)
+ {
+ formattedNumber = nationalFormat;
+ break;
+ }
+ // When the format we apply to this number doesn't contain national
+ // prefix, we can just return the national format.
+ // TODO: Refactor the code below with the code in
+ // isNationalPrefixPresentIfRequired.
+ NSString *candidateNationalPrefixRule = formatRule.nationalPrefixFormattingRule;
+ // We assume that the first-group symbol will never be _before_ the
+ // national prefix.
+ NSRange firstGroupRange = [candidateNationalPrefixRule rangeOfString:@"$1"];
+ if (firstGroupRange.location == NSNotFound)
+ {
+ formattedNumber = nationalFormat;
+ break;
+ }
+
+ if (firstGroupRange.location <= 0)
+ {
+ formattedNumber = nationalFormat;
+ break;
+ }
+ candidateNationalPrefixRule = [candidateNationalPrefixRule substringWithRange:NSMakeRange(0, firstGroupRange.location)];
+ candidateNationalPrefixRule = [self normalizeDigitsOnly:candidateNationalPrefixRule];
+ if (candidateNationalPrefixRule.length == 0)
+ {
+ // National prefix not used when formatting this number.
+ formattedNumber = nationalFormat;
+ break;
+ }
+ // Otherwise, we need to remove the national prefix from our output.
+ NBNumberFormat *numFormatCopy = [formatRule copy];
+ numFormatCopy.nationalPrefixFormattingRule = nil;
+ formattedNumber = [self formatByPattern:number numberFormat:NBEPhoneNumberFormatNATIONAL userDefinedFormats:@[numFormatCopy]];
+ break;
+ }
+ }
+
+ NSString *rawInput = number.rawInput;
+ // If no digit is inserted/removed/modified as a result of our formatting, we
+ // return the formatted phone number; otherwise we return the raw input the
+ // user entered.
+ if (formattedNumber != nil && rawInput.length > 0)
+ {
+ NSString *normalizedFormattedNumber = [self normalizeHelper:formattedNumber normalizationReplacements:_DIALLABLE_CHAR_MAPPINGS_ removeNonMatches:YES];
+ /** @type {string} */
+ NSString *normalizedRawInput =[self normalizeHelper:rawInput normalizationReplacements:_DIALLABLE_CHAR_MAPPINGS_ removeNonMatches:YES];
+
+ if ([normalizedFormattedNumber isEqualToString:normalizedRawInput] == NO)
+ {
+ formattedNumber = rawInput;
+ }
+ }
+ return formattedNumber;
+}
+
+
+/**
+ * Check if rawInput, which is assumed to be in the national format, has a
+ * national prefix. The national prefix is assumed to be in digits-only form.
+ * @param {string} rawInput
+ * @param {string} nationalPrefix
+ * @param {string} regionCode
+ * @return {boolean}
+ * @private
+ */
+- (BOOL)rawInputContainsNationalPrefix:(NSString*)rawInput nationalPrefix:(NSString*)nationalPrefix regionCode:(NSString*)regionCode
+{
+ NSString *normalizedNationalNumber = [self normalizeDigitsOnly:rawInput];
+ if ([self isStartingStringByRegex:normalizedNationalNumber regex:nationalPrefix])
+ {
+ @try {
+ // Some Japanese numbers (e.g. 00777123) might be mistaken to contain the
+ // national prefix when written without it (e.g. 0777123) if we just do
+ // prefix matching. To tackle that, we check the validity of the number if
+ // the assumed national prefix is removed (777123 won't be valid in
+ // Japan).
+ NSString *subString = [normalizedNationalNumber substringFromIndex:nationalPrefix.length];
+ return [self isValidNumber:[self parse:subString defaultRegion:regionCode]];
+ }
+ @catch (NSException *ex) {
+ return NO;
+ }
+ }
+ return NO;
+}
+
+
+/**
+ * Returns NO if a number is from a region whose national significant number
+ * couldn't contain a leading zero, but has the italian_leading_zero field set
+ * to NO.
+ * @param {i18n.phonenumbers.PhoneNumber} number
+ * @return {boolean}
+ * @private
+ */
+- (BOOL)hasUnexpectedItalianLeadingZero:(NBPhoneNumber*)number
+{
+ return number.italianLeadingZero && [self isLeadingZeroPossible:number.countryCode] == NO;
+}
+
+
+/**
+ * @param {i18n.phonenumbers.PhoneNumber} number
+ * @return {boolean}
+ * @private
+ */
+- (BOOL)hasFormattingPatternForNumber:(NBPhoneNumber*)number
+{
+ NSNumber *countryCallingCode = number.countryCode;
+ NSString *phoneNumberRegion = [self getRegionCodeForCountryCode:countryCallingCode];
+ NBPhoneMetaData *metadata = [self getMetadataForRegionOrCallingCode:countryCallingCode regionCode:phoneNumberRegion];
+
+ if (metadata == nil)
+ {
+ return NO;
+ }
+
+ NSString *nationalNumber = [self getNationalSignificantNumber:number];
+ NBNumberFormat *formatRule = [self chooseFormattingPatternForNumber:metadata.numberFormats nationalNumber:nationalNumber];
+ return formatRule != nil;
+}
+
+
+/**
+ * Formats a phone number for out-of-country dialing purposes.
+ *
+ * Note that in this version, if the number was entered originally using alpha
+ * characters and this version of the number is stored in raw_input, this
+ * representation of the number will be used rather than the digit
+ * representation. Grouping information, as specified by characters such as '-'
+ * and ' ', will be retained.
+ *
+ * <p><b>Caveats:</b></p>
+ * <ul>
+ * <li>This will not produce good results if the country calling code is both
+ * present in the raw input _and_ is the start of the national number. This is
+ * not a problem in the regions which typically use alpha numbers.
+ * <li>This will also not produce good results if the raw input has any grouping
+ * information within the first three digits of the national number, and if the
+ * function needs to strip preceding digits/words in the raw input before these
+ * digits. Normally people group the first three digits together so this is not
+ * a huge problem - and will be fixed if it proves to be so.
+ * </ul>
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number that needs to
+ * be formatted.
+ * @param {string} regionCallingFrom the region where the call is being placed.
+ * @return {string} the formatted phone number.
+ */
+- (NSString*)formatOutOfCountryKeepingAlphaChars:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom error:(NSError **)error
+{
+ NSString *res = nil;
+ @try {
+ res = [self formatOutOfCountryKeepingAlphaChars:number regionCallingFrom:regionCallingFrom];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (NSString*)formatOutOfCountryKeepingAlphaChars:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom
+{
+ NSString *rawInput = number.rawInput;
+ // If there is no raw input, then we can't keep alpha characters because there
+ // aren't any. In this case, we return formatOutOfCountryCallingNumber.
+ if (rawInput == nil || rawInput.length == 0)
+ {
+ return [self formatOutOfCountryCallingNumber:number regionCallingFrom:regionCallingFrom];
+ }
+
+ NSNumber *countryCode = number.countryCode;
+ if ([self hasValidCountryCallingCode:countryCode] == NO)
+ {
+ return rawInput;
+ }
+ // Strip any prefix such as country calling code, IDD, that was present. We do
+ // this by comparing the number in raw_input with the parsed number. To do
+ // this, first we normalize punctuation. We retain number grouping symbols
+ // such as ' ' only.
+ rawInput = [self normalizeHelper:rawInput normalizationReplacements:_ALL_PLUS_NUMBER_GROUPING_SYMBOLS_ removeNonMatches:NO];
+ //NSLog(@"---- formatOutOfCountryKeepingAlphaChars normalizeHelper rawInput [%@]", rawInput);
+ // Now we trim everything before the first three digits in the parsed number.
+ // We choose three because all valid alpha numbers have 3 digits at the start
+ // - if it does not, then we don't trim anything at all. Similarly, if the
+ // national number was less than three digits, we don't trim anything at all.
+ NSString *nationalNumber = [self getNationalSignificantNumber:number];
+ if (nationalNumber.length > 3)
+ {
+ NSInteger firstNationalNumberDigit = [self indexOfStringByString:rawInput target:[nationalNumber substringWithRange:NSMakeRange(0, 3)]];
+ if (firstNationalNumberDigit != -1)
+ {
+ rawInput = [rawInput substringFromIndex:firstNationalNumberDigit];
+ }
+ }
+
+ NBPhoneMetaData *metadataForRegionCallingFrom = [self getMetadataForRegion:regionCallingFrom];
+ if ([countryCode isEqualToNumber: @(NANPA_COUNTRY_CODE_)])
+ {
+ if ([self isNANPACountry:regionCallingFrom])
+ {
+ return [NSString stringWithFormat:@"%@ %@", countryCode, rawInput];
+ }
+ }
+ else if (metadataForRegionCallingFrom != nil && [countryCode isEqualToNumber: [self getCountryCodeForValidRegion:regionCallingFrom]])
+ {
+ NBNumberFormat *formattingPattern = [self chooseFormattingPatternForNumber:metadataForRegionCallingFrom.numberFormats
+ nationalNumber:nationalNumber];
+ if (formattingPattern == nil)
+ {
+ // If no pattern above is matched, we format the original input.
+ return rawInput;
+ }
+
+ NBNumberFormat *newFormat = [formattingPattern copy];
+ // The first group is the first group of digits that the user wrote
+ // together.
+ newFormat.pattern = @"(\\d+)(.*)";
+ // Here we just concatenate them back together after the national prefix
+ // has been fixed.
+ newFormat.format = @"$1$2";
+ // Now we format using this pattern instead of the default pattern, but
+ // with the national prefix prefixed if necessary.
+ // This will not work in the cases where the pattern (and not the leading
+ // digits) decide whether a national prefix needs to be used, since we have
+ // overridden the pattern to match anything, but that is not the case in the
+ // metadata to date.
+
+ return [self formatNsnUsingPattern:rawInput formattingPattern:newFormat numberFormat:NBEPhoneNumberFormatNATIONAL carrierCode:nil];
+ }
+
+ NSString *internationalPrefixForFormatting = @"";
+ // If an unsupported region-calling-from is entered, or a country with
+ // multiple international prefixes, the international format of the number is
+ // returned, unless there is a preferred international prefix.
+ if (metadataForRegionCallingFrom != nil)
+ {
+ NSString *internationalPrefix = metadataForRegionCallingFrom.internationalPrefix;
+ internationalPrefixForFormatting =
+ [self matchesEntirely:UNIQUE_INTERNATIONAL_PREFIX_ string:internationalPrefix] ? internationalPrefix : metadataForRegionCallingFrom.preferredInternationalPrefix;
+ }
+
+ NSString *regionCode = [self getRegionCodeForCountryCode:countryCode];
+ // Metadata cannot be nil because the country calling code is valid.
+ NBPhoneMetaData *metadataForRegion = [self getMetadataForRegionOrCallingCode:countryCode regionCode:regionCode];
+ NSString *formattedExtension = [self maybeGetFormattedExtension:number metadata:metadataForRegion numberFormat:NBEPhoneNumberFormatINTERNATIONAL];
+ if (internationalPrefixForFormatting.length > 0)
+ {
+ return [NSString stringWithFormat:@"%@ %@ %@%@", internationalPrefixForFormatting, countryCode, rawInput, formattedExtension];
+ }
+ else
+ {
+ // Invalid region entered as country-calling-from (so no metadata was found
+ // for it) or the region chosen has multiple international dialling
+ // prefixes.
+ return [self prefixNumberWithCountryCallingCode:countryCode phoneNumberFormat:NBEPhoneNumberFormatINTERNATIONAL formattedNationalNumber:rawInput formattedExtension:formattedExtension];
+ }
+}
+
+
+/**
+ * Note in some regions, the national number can be written in two completely
+ * different ways depending on whether it forms part of the NATIONAL format or
+ * INTERNATIONAL format. The numberFormat parameter here is used to specify
+ * which format to use for those cases. If a carrierCode is specified, this will
+ * be inserted into the formatted string to replace $CC.
+ *
+ * @param {string} number a string of characters representing a phone number.
+ * @param {i18n.phonenumbers.PhoneMetadata} metadata the metadata for the
+ * region that we think this number is from.
+ * @param {i18n.phonenumbers.PhoneNumberFormat} numberFormat the format the
+ * phone number should be formatted into.
+ * @param {string=} opt_carrierCode
+ * @return {string} the formatted phone number.
+ * @private
+ */
+- (NSString*)formatNsn:(NSString*)phoneNumber metadata:(NBPhoneMetaData*)metadata phoneNumberFormat:(NBEPhoneNumberFormat)numberFormat carrierCode:(NSString*)opt_carrierCode
+{
+ NSMutableArray *intlNumberFormats = metadata.intlNumberFormats;
+ // When the intlNumberFormats exists, we use that to format national number
+ // for the INTERNATIONAL format instead of using the numberDesc.numberFormats.
+ NSArray *availableFormats = ([intlNumberFormats count] <= 0 || numberFormat == NBEPhoneNumberFormatNATIONAL) ? metadata.numberFormats : intlNumberFormats;
+ NBNumberFormat *formattingPattern = [self chooseFormattingPatternForNumber:availableFormats nationalNumber:phoneNumber];
+
+ if (formattingPattern == nil)
+ {
+ return phoneNumber;
+ }
+
+ return [self formatNsnUsingPattern:phoneNumber formattingPattern:formattingPattern numberFormat:numberFormat carrierCode:opt_carrierCode];
+}
+
+
+/**
+ * @param {Array.<i18n.phonenumbers.NumberFormat>} availableFormats the
+ * available formats the phone number could be formatted into.
+ * @param {string} nationalNumber a string of characters representing a phone
+ * number.
+ * @return {i18n.phonenumbers.NumberFormat}
+ * @private
+ */
+- (NBNumberFormat*)chooseFormattingPatternForNumber:(NSArray*)availableFormats nationalNumber:(NSString*)nationalNumber
+{
+ for (NBNumberFormat *numFormat in availableFormats)
+ {
+ NSUInteger size = [numFormat.leadingDigitsPatterns count];
+ // We always use the last leading_digits_pattern, as it is the most detailed.
+ if (size == 0 || [self stringPositionByRegex:nationalNumber regex:[numFormat.leadingDigitsPatterns lastObject]] == 0)
+ {
+ if ([self matchesEntirely:numFormat.pattern string:nationalNumber])
+ {
+ return numFormat;
+ }
+ }
+ }
+
+ return nil;
+}
+
+
+/**
+ * Note that carrierCode is optional - if nil or an empty string, no carrier
+ * code replacement will take place.
+ *
+ * @param {string} nationalNumber a string of characters representing a phone
+ * number.
+ * @param {i18n.phonenumbers.NumberFormat} formattingPattern the formatting rule
+ * the phone number should be formatted into.
+ * @param {i18n.phonenumbers.PhoneNumberFormat} numberFormat the format the
+ * phone number should be formatted into.
+ * @param {string=} opt_carrierCode
+ * @return {string} the formatted phone number.
+ * @private
+ */
+- (NSString*)formatNsnUsingPattern:(NSString*)nationalNumber formattingPattern:(NBNumberFormat*)formattingPattern numberFormat:(NBEPhoneNumberFormat)numberFormat carrierCode:(NSString*)opt_carrierCode
+{
+ NSString *numberFormatRule = formattingPattern.format;
+ NSString *domesticCarrierCodeFormattingRule = formattingPattern.domesticCarrierCodeFormattingRule;
+ NSString *formattedNationalNumber = @"";
+
+ if (numberFormat == NBEPhoneNumberFormatNATIONAL && [self hasValue:opt_carrierCode] && domesticCarrierCodeFormattingRule.length > 0)
+ {
+ // Replace the $CC in the formatting rule with the desired carrier code.
+ NSString *carrierCodeFormattingRule = [self replaceStringByRegex:domesticCarrierCodeFormattingRule regex:CC_PATTERN_ withTemplate:opt_carrierCode];
+ // Now replace the $FG in the formatting rule with the first group and
+ // the carrier code combined in the appropriate way.
+ numberFormatRule = [self replaceFirstStringByRegex:numberFormatRule regex:FIRST_GROUP_PATTERN_
+ withTemplate:carrierCodeFormattingRule];
+ formattedNationalNumber = [self replaceStringByRegex:nationalNumber regex:formattingPattern.pattern withTemplate:numberFormatRule];
+ }
+ else
+ {
+ // Use the national prefix formatting rule instead.
+ NSString *nationalPrefixFormattingRule = formattingPattern.nationalPrefixFormattingRule;
+ if (numberFormat == NBEPhoneNumberFormatNATIONAL && [self hasValue:nationalPrefixFormattingRule])
+ {
+ NSString *replacePattern = [self replaceFirstStringByRegex:numberFormatRule regex:FIRST_GROUP_PATTERN_ withTemplate:nationalPrefixFormattingRule];
+ formattedNationalNumber = [self replaceStringByRegex:nationalNumber regex:formattingPattern.pattern withTemplate:replacePattern];
+ }
+ else
+ {
+ formattedNationalNumber = [self replaceStringByRegex:nationalNumber regex:formattingPattern.pattern withTemplate:numberFormatRule];
+ }
+ }
+
+ if (numberFormat == NBEPhoneNumberFormatRFC3966)
+ {
+ // Strip any leading punctuation.
+ formattedNationalNumber = [self replaceStringByRegex:formattedNationalNumber regex:[NSString stringWithFormat:@"^%@", self.SEPARATOR_PATTERN_] withTemplate:@""];
+
+ // Replace the rest with a dash between each number group.
+ formattedNationalNumber = [self replaceStringByRegex:formattedNationalNumber regex:self.SEPARATOR_PATTERN_ withTemplate:@"-"];
+ }
+ return formattedNationalNumber;
+}
+
+
+/**
+ * Gets a valid number for the specified region.
+ *
+ * @param {string} regionCode the region for which an example number is needed.
+ * @return {i18n.phonenumbers.PhoneNumber} a valid fixed-line number for the
+ * specified region. Returns nil when the metadata does not contain such
+ * information, or the region 001 is passed in. For 001 (representing non-
+ * geographical numbers), call {@link #getExampleNumberForNonGeoEntity}
+ * instead.
+ */
+- (NBPhoneNumber*)getExampleNumber:(NSString*)regionCode error:(NSError *__autoreleasing *)error
+{
+ NBPhoneNumber *res = nil;
+ @try {
+ res = [self getExampleNumber:regionCode];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (NBPhoneNumber*)getExampleNumber:(NSString*)regionCode
+{
+ return [self getExampleNumberForType:regionCode type:NBEPhoneNumberTypeFIXED_LINE];
+}
+
+
+/**
+ * Gets a valid number for the specified region and number type.
+ *
+ * @param {string} regionCode the region for which an example number is needed.
+ * @param {i18n.phonenumbers.PhoneNumberType} type the type of number that is
+ * needed.
+ * @return {i18n.phonenumbers.PhoneNumber} a valid number for the specified
+ * region and type. Returns nil when the metadata does not contain such
+ * information or if an invalid region or region 001 was entered.
+ * For 001 (representing non-geographical numbers), call
+ * {@link #getExampleNumberForNonGeoEntity} instead.
+ */
+- (NBPhoneNumber*)getExampleNumberForType:(NSString*)regionCode type:(NBEPhoneNumberType)type error:(NSError *__autoreleasing *)error
+{
+ NBPhoneNumber *res = nil;
+ @try {
+ res = [self getExampleNumberForType:regionCode type:type];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (NBPhoneNumber*)getExampleNumberForType:(NSString*)regionCode type:(NBEPhoneNumberType)type
+{
+ // Check the region code is valid.
+ if ([self isValidRegionCode:regionCode] == NO)
+ {
+ return nil;
+ }
+
+ NBPhoneNumberDesc *desc = [self getNumberDescByType:[self getMetadataForRegion:regionCode] type:type];
+
+ @try {
+ if ([self hasValue:desc.exampleNumber ])
+ {
+ return [self parse:desc.exampleNumber defaultRegion:regionCode];
+ }
+ }
+ @catch (NSException *e)
+ {
+ }
+
+ return nil;
+}
+
+
+/**
+ * Gets a valid number for the specified country calling code for a
+ * non-geographical entity.
+ *
+ * @param {number} countryCallingCode the country calling code for a
+ * non-geographical entity.
+ * @return {i18n.phonenumbers.PhoneNumber} a valid number for the
+ * non-geographical entity. Returns nil when the metadata does not contain
+ * such information, or the country calling code passed in does not belong
+ * to a non-geographical entity.
+ */
+- (NBPhoneNumber*)getExampleNumberForNonGeoEntity:(NSNumber*)countryCallingCode error:(NSError *__autoreleasing *)error
+{
+ NBPhoneNumber *res = nil;
+ @try {
+ res = [self getExampleNumberForNonGeoEntity:countryCallingCode];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (NBPhoneNumber*)getExampleNumberForNonGeoEntity:(NSNumber*)countryCallingCode
+{
+ NBPhoneMetaData *metadata = [self getMetadataForNonGeographicalRegion:countryCallingCode];
+
+ if (metadata != nil)
+ {
+ NBPhoneNumberDesc *desc = metadata.generalDesc;
+ @try {
+ if ([self hasValue:desc.exampleNumber])
+ {
+ NSString *callCode = [NSString stringWithFormat:@"+%@%@", countryCallingCode, desc.exampleNumber];
+ return [self parse:callCode defaultRegion:UNKNOWN_REGION_];
+ }
+ }
+ @catch (NSException *e) {
+ }
+ }
+ return nil;
+}
+
+
+/**
+ * Gets the formatted extension of a phone number, if the phone number had an
+ * extension specified. If not, it returns an empty string.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the PhoneNumber that might have
+ * an extension.
+ * @param {i18n.phonenumbers.PhoneMetadata} metadata the metadata for the
+ * region that we think this number is from.
+ * @param {i18n.phonenumbers.PhoneNumberFormat} numberFormat the format the
+ * phone number should be formatted into.
+ * @return {string} the formatted extension if any.
+ * @private
+ */
+- (NSString*)maybeGetFormattedExtension:(NBPhoneNumber*)number metadata:(NBPhoneMetaData*)metadata numberFormat:(NBEPhoneNumberFormat)numberFormat
+{
+ if ([self hasValue:number.extension] == NO)
+ {
+ return @"";
+ }
+ else
+ {
+ if (numberFormat == NBEPhoneNumberFormatRFC3966)
+ {
+ return [NSString stringWithFormat:@"%@%@", RFC3966_EXTN_PREFIX_, number.extension];
+ }
+ else
+ {
+ if ([self hasValue:metadata.preferredExtnPrefix])
+ {
+ return [NSString stringWithFormat:@"%@%@", metadata.preferredExtnPrefix, number.extension];
+ }
+ else
+ {
+ return [NSString stringWithFormat:@"%@%@", DEFAULT_EXTN_PREFIX_, number.extension];
+ }
+ }
+ }
+}
+
+
+/**
+ * @param {i18n.phonenumbers.PhoneMetadata} metadata
+ * @param {i18n.phonenumbers.PhoneNumberType} type
+ * @return {i18n.phonenumbers.PhoneNumberDesc}
+ * @private
+ */
+- (NBPhoneNumberDesc*)getNumberDescByType:(NBPhoneMetaData*)metadata type:(NBEPhoneNumberType)type
+{
+ switch (type)
+ {
+ case NBEPhoneNumberTypePREMIUM_RATE:
+ return metadata.premiumRate;
+ case NBEPhoneNumberTypeTOLL_FREE:
+ return metadata.tollFree;
+ case NBEPhoneNumberTypeMOBILE:
+ if (metadata.mobile == nil) return metadata.generalDesc;
+ return metadata.mobile;
+ case NBEPhoneNumberTypeFIXED_LINE:
+ case NBEPhoneNumberTypeFIXED_LINE_OR_MOBILE:
+ if (metadata.fixedLine == nil) return metadata.generalDesc;
+ return metadata.fixedLine;
+ case NBEPhoneNumberTypeSHARED_COST:
+ return metadata.sharedCost;
+ case NBEPhoneNumberTypeVOIP:
+ return metadata.voip;
+ case NBEPhoneNumberTypePERSONAL_NUMBER:
+ return metadata.personalNumber;
+ case NBEPhoneNumberTypePAGER:
+ return metadata.pager;
+ case NBEPhoneNumberTypeUAN:
+ return metadata.uan;
+ case NBEPhoneNumberTypeVOICEMAIL:
+ return metadata.voicemail;
+ default:
+ return metadata.generalDesc;
+ }
+}
+
+/**
+ * Gets the type of a phone number.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number that we want
+ * to know the type.
+ * @return {i18n.phonenumbers.PhoneNumberType} the type of the phone number.
+ */
+- (NBEPhoneNumberType)getNumberType:(NBPhoneNumber*)phoneNumber
+{
+ NSString *regionCode = [self getRegionCodeForNumber:phoneNumber];
+ NBPhoneMetaData *metadata = [self getMetadataForRegionOrCallingCode:phoneNumber.countryCode regionCode:regionCode];
+ if (metadata == nil)
+ {
+ return NBEPhoneNumberTypeUNKNOWN;
+ }
+
+ NSString *nationalSignificantNumber = [self getNationalSignificantNumber:phoneNumber];
+ return [self getNumberTypeHelper:nationalSignificantNumber metadata:metadata];
+}
+
+
+/**
+ * @param {string} nationalNumber
+ * @param {i18n.phonenumbers.PhoneMetadata} metadata
+ * @return {i18n.phonenumbers.PhoneNumberType}
+ * @private
+ */
+- (NBEPhoneNumberType)getNumberTypeHelper:(NSString*)nationalNumber metadata:(NBPhoneMetaData*)metadata
+{
+ NBPhoneNumberDesc *generalNumberDesc = metadata.generalDesc;
+
+ //NSLog(@"getNumberTypeHelper - UNKNOWN 1");
+ if ([self hasValue:generalNumberDesc.nationalNumberPattern] == NO ||
+ [self isNumberMatchingDesc:nationalNumber numberDesc:generalNumberDesc] == NO)
+ {
+ //NSLog(@"getNumberTypeHelper - UNKNOWN 2");
+ return NBEPhoneNumberTypeUNKNOWN;
+ }
+
+ //NSLog(@"getNumberTypeHelper - PREMIUM_RATE 1");
+ if ([self isNumberMatchingDesc:nationalNumber numberDesc:metadata.premiumRate])
+ {
+ //NSLog(@"getNumberTypeHelper - PREMIUM_RATE 2");
+ return NBEPhoneNumberTypePREMIUM_RATE;
+ }
+
+ //NSLog(@"getNumberTypeHelper - TOLL_FREE 1");
+ if ([self isNumberMatchingDesc:nationalNumber numberDesc:metadata.tollFree])
+ {
+ //NSLog(@"getNumberTypeHelper - TOLL_FREE 2");
+ return NBEPhoneNumberTypeTOLL_FREE;
+ }
+
+ //NSLog(@"getNumberTypeHelper - SHARED_COST 1");
+ if ([self isNumberMatchingDesc:nationalNumber numberDesc:metadata.sharedCost])
+ {
+ //NSLog(@"getNumberTypeHelper - SHARED_COST 2");
+ return NBEPhoneNumberTypeSHARED_COST;
+ }
+
+ //NSLog(@"getNumberTypeHelper - VOIP 1");
+ if ([self isNumberMatchingDesc:nationalNumber numberDesc:metadata.voip])
+ {
+ //NSLog(@"getNumberTypeHelper - VOIP 2");
+ return NBEPhoneNumberTypeVOIP;
+ }
+
+ //NSLog(@"getNumberTypeHelper - PERSONAL_NUMBER 1");
+ if ([self isNumberMatchingDesc:nationalNumber numberDesc:metadata.personalNumber])
+ {
+ //NSLog(@"getNumberTypeHelper - PERSONAL_NUMBER 2");
+ return NBEPhoneNumberTypePERSONAL_NUMBER;
+ }
+
+ //NSLog(@"getNumberTypeHelper - PAGER 1");
+ if ([self isNumberMatchingDesc:nationalNumber numberDesc:metadata.pager])
+ {
+ //NSLog(@"getNumberTypeHelper - PAGER 2");
+ return NBEPhoneNumberTypePAGER;
+ }
+
+ //NSLog(@"getNumberTypeHelper - UAN 1");
+ if ([self isNumberMatchingDesc:nationalNumber numberDesc:metadata.uan])
+ {
+ //NSLog(@"getNumberTypeHelper - UAN 2");
+ return NBEPhoneNumberTypeUAN;
+ }
+
+ //NSLog(@"getNumberTypeHelper - VOICEMAIL 1");
+ if ([self isNumberMatchingDesc:nationalNumber numberDesc:metadata.voicemail])
+ {
+ //NSLog(@"getNumberTypeHelper - VOICEMAIL 2");
+ return NBEPhoneNumberTypeVOICEMAIL;
+ }
+
+ if ([self isNumberMatchingDesc:nationalNumber numberDesc:metadata.fixedLine])
+ {
+ if (metadata.sameMobileAndFixedLinePattern)
+ {
+ //NSLog(@"getNumberTypeHelper - FIXED_LINE_OR_MOBILE");
+ return NBEPhoneNumberTypeFIXED_LINE_OR_MOBILE;
+ }
+ else if ([self isNumberMatchingDesc:nationalNumber numberDesc:metadata.mobile])
+ {
+ //NSLog(@"getNumberTypeHelper - FIXED_LINE_OR_MOBILE");
+ return NBEPhoneNumberTypeFIXED_LINE_OR_MOBILE;
+ }
+ //NSLog(@"getNumberTypeHelper - FIXED_LINE");
+ return NBEPhoneNumberTypeFIXED_LINE;
+ }
+
+ // Otherwise, test to see if the number is mobile. Only do this if certain
+ // that the patterns for mobile and fixed line aren't the same.
+ if ([metadata sameMobileAndFixedLinePattern] == NO && [self isNumberMatchingDesc:nationalNumber numberDesc:metadata.mobile])
+ {
+ return NBEPhoneNumberTypeMOBILE;
+ }
+
+ return NBEPhoneNumberTypeUNKNOWN;
+}
+
+
+/**
+ * Returns the metadata for the given region code or {@code nil} if the region
+ * code is invalid or unknown.
+ *
+ * @param {?string} regionCode
+ * @return {i18n.phonenumbers.PhoneMetadata}
+ */
+- (NBPhoneMetaData*)getMetadataForRegion:(NSString*)regionCode
+{
+ if ([self hasValue:regionCode] == NO)
+ {
+ return nil;
+ }
+
+ regionCode = [regionCode uppercaseString];
+
+ NBPhoneMetaData *metadata = [self.coreMetaData objectForKey:regionCode];
+
+ return metadata;
+}
+
+
+/**
+ * @param {number} countryCallingCode
+ * @return {i18n.phonenumbers.PhoneMetadata}
+ */
+- (NBPhoneMetaData*)getMetadataForNonGeographicalRegion:(NSNumber*)countryCallingCode
+{
+ NSString *countryCallingCodeStr = [NSString stringWithFormat:@"%@", countryCallingCode];
+ return [self getMetadataForRegion:countryCallingCodeStr];
+}
+
+
+/**
+ * @param {string} nationalNumber
+ * @param {i18n.phonenumbers.PhoneNumberDesc} numberDesc
+ * @return {boolean}
+ * @private
+ */
+- (BOOL)isNumberMatchingDesc:(NSString*)nationalNumber numberDesc:(NBPhoneNumberDesc*)numberDesc
+{
+ if (numberDesc == nil)
+ return NO;
+
+ if ([self hasValue:numberDesc.possibleNumberPattern] == NO || [numberDesc.possibleNumberPattern isEqual:@"NA"])
+ return [self matchesEntirely:numberDesc.nationalNumberPattern string:nationalNumber];
+
+ if ([self hasValue:numberDesc.nationalNumberPattern] == NO || [numberDesc.nationalNumberPattern isEqual:@"NA"])
+ return [self matchesEntirely:numberDesc.possibleNumberPattern string:nationalNumber];
+
+ return [self matchesEntirely:numberDesc.possibleNumberPattern string:nationalNumber] &&
+ [self matchesEntirely:numberDesc.nationalNumberPattern string:nationalNumber];
+}
+
+
+/**
+ * Tests whether a phone number matches a valid pattern. Note this doesn't
+ * verify the number is actually in use, which is impossible to tell by just
+ * looking at a number itself.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number that we want
+ * to validate.
+ * @return {boolean} a boolean that indicates whether the number is of a valid
+ * pattern.
+ */
+- (BOOL)isValidNumber:(NBPhoneNumber*)number
+{
+ NSString *regionCode = [self getRegionCodeForNumber:number];
+ return [self isValidNumberForRegion:number regionCode:regionCode];
+}
+
+
+/**
+ * Tests whether a phone number is valid for a certain region. Note this doesn't
+ * verify the number is actually in use, which is impossible to tell by just
+ * looking at a number itself. If the country calling code is not the same as
+ * the country calling code for the region, this immediately exits with NO.
+ * After this, the specific number pattern rules for the region are examined.
+ * This is useful for determining for example whether a particular number is
+ * valid for Canada, rather than just a valid NANPA number.
+ * Warning: In most cases, you want to use {@link #isValidNumber} instead. For
+ * example, this method will mark numbers from British Crown dependencies such
+ * as the Isle of Man as invalid for the region "GB" (United Kingdom), since it
+ * has its own region code, "IM", which may be undesirable.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number that we want
+ * to validate.
+ * @param {?string} regionCode the region that we want to validate the phone
+ * number for.
+ * @return {boolean} a boolean that indicates whether the number is of a valid
+ * pattern.
+ */
+- (BOOL)isValidNumberForRegion:(NBPhoneNumber*)number regionCode:(NSString*)regionCode
+{
+ NSNumber *countryCode = number.countryCode;
+
+ NBPhoneMetaData *metadata = [self getMetadataForRegionOrCallingCode:countryCode regionCode:regionCode];
+ if (metadata == nil ||
+ ([_REGION_CODE_FOR_NON_GEO_ENTITY isEqualToString:regionCode] == NO &&
+ ![countryCode isEqualToNumber: [self getCountryCodeForValidRegion:regionCode]]))
+ {
+ // Either the region code was invalid, or the country calling code for this
+ // number does not match that of the region code.
+ return NO;
+ }
+
+ NBPhoneNumberDesc *generalNumDesc = metadata.generalDesc;
+ NSString *nationalSignificantNumber = [self getNationalSignificantNumber:number];
+
+ // For regions where we don't have metadata for PhoneNumberDesc, we treat any
+ // number passed in as a valid number if its national significant number is
+ // between the minimum and maximum lengths defined by ITU for a national
+ // significant number.
+ if ([self hasValue:generalNumDesc.nationalNumberPattern] == NO)
+ {
+ NSUInteger numberLength = nationalSignificantNumber.length;
+ return numberLength > MIN_LENGTH_FOR_NSN_ && numberLength <= MAX_LENGTH_FOR_NSN_;
+ }
+
+ return [self getNumberTypeHelper:nationalSignificantNumber metadata:metadata] != NBEPhoneNumberTypeUNKNOWN;
+}
+
+
+/**
+ * Returns the region where a phone number is from. This could be used for
+ * geocoding at the region level.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone number whose origin
+ * we want to know.
+ * @return {?string} the region where the phone number is from, or nil
+ * if no region matches this calling code.
+ */
+- (NSString*)getRegionCodeForNumber:(NBPhoneNumber*)phoneNumber
+{
+ if (phoneNumber == nil)
+ {
+ return nil;
+ }
+
+ NSArray *regionCodes = [self regionCodeFromCountryCode:phoneNumber.countryCode];
+ if (regionCodes == nil || [regionCodes count] <= 0)
+ {
+ return nil;
+ }
+
+ if ([regionCodes count] == 1)
+ {
+ return [regionCodes objectAtIndex:0];
+ }
+ else
+ {
+ return [self getRegionCodeForNumberFromRegionList:phoneNumber regionCodes:regionCodes];
+ }
+}
+
+
+/**
+ * @param {i18n.phonenumbers.PhoneNumber} number
+ * @param {Array.<string>} regionCodes
+ * @return {?string}
+ * @private
+
+ */
+- (NSString*)getRegionCodeForNumberFromRegionList:(NBPhoneNumber*)phoneNumber regionCodes:(NSArray*)regionCodes
+{
+ NSString *nationalNumber = [self getNationalSignificantNumber:phoneNumber];
+ NSUInteger regionCodesCount = [regionCodes count];
+
+ for (NSUInteger i = 0; i<regionCodesCount; i++)
+ {
+ NSString *regionCode = [regionCodes objectAtIndex:i];
+ NBPhoneMetaData *metadata = [self getMetadataForRegion:regionCode];
+
+ if ([self hasValue:metadata.leadingDigits])
+ {
+ if ([self stringPositionByRegex:nationalNumber regex:metadata.leadingDigits] == 0)
+ {
+ return regionCode;
+ }
+ }
+ else if ([self getNumberTypeHelper:nationalNumber metadata:metadata] != NBEPhoneNumberTypeUNKNOWN)
+ {
+ return regionCode;
+ }
+ }
+
+ return nil;
+}
+
+
+/**
+ * Returns the region code that matches the specific country calling code. In
+ * the case of no region code being found, ZZ will be returned. In the case of
+ * multiple regions, the one designated in the metadata as the 'main' region for
+ * this calling code will be returned.
+ *
+ * @param {number} countryCallingCode the country calling code.
+ * @return {string}
+ */
+- (NSString*)getRegionCodeForCountryCode:(NSNumber*)countryCallingCode
+{
+ NSArray *regionCodes = [self regionCodeFromCountryCode:countryCallingCode];
+ return regionCodes == nil ? UNKNOWN_REGION_ : [regionCodes objectAtIndex:0];
+}
+
+
+/**
+ * Returns a list with the region codes that match the specific country calling
+ * code. For non-geographical country calling codes, the region code 001 is
+ * returned. Also, in the case of no region code being found, an empty list is
+ * returned.
+ *
+ * @param {number} countryCallingCode the country calling code.
+ * @return {Array.<string>}
+ */
+- (NSArray*)getRegionCodesForCountryCode:(NSNumber*)countryCallingCode
+{
+ NSArray *regionCodes = [self regionCodeFromCountryCode:countryCallingCode];
+ return regionCodes == nil ? nil : regionCodes;
+}
+
+
+/**
+ * Returns the country calling code for a specific region. For example, this
+ * would be 1 for the United States, and 64 for New Zealand.
+ *
+ * @param {?string} regionCode the region that we want to get the country
+ * calling code for.
+ * @return {number} the country calling code for the region denoted by
+ * regionCode.
+ */
+- (NSNumber*)getCountryCodeForRegion:(NSString*)regionCode
+{
+ if ([self isValidRegionCode:regionCode] == NO)
+ {
+ return @0;
+ }
+
+ NSError *error = nil;
+ NSNumber *res = [self getCountryCodeForValidRegion:regionCode error:&error];
+ if (error != nil)
+ return @0;
+ return res;
+}
+
+
+/**
+ * Returns the country calling code for a specific region. For example, this
+ * would be 1 for the United States, and 64 for New Zealand. Assumes the region
+ * is already valid.
+ *
+ * @param {?string} regionCode the region that we want to get the country
+ * calling code for.
+ * @return {number} the country calling code for the region denoted by
+ * regionCode.
+ * @throws {string} if the region is invalid
+ * @private
+ */
+- (NSNumber *)getCountryCodeForValidRegion:(NSString*)regionCode error:(NSError**)error
+{
+ NSNumber * res = nil;
+ @try {
+ res = [self getCountryCodeForValidRegion:regionCode];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+- (NSNumber *)getCountryCodeForValidRegion:(NSString*)regionCode
+{
+ NBPhoneMetaData *metadata = [self getMetadataForRegion:regionCode];
+ if (metadata == nil)
+ {
+ NSException* metaException = [NSException exceptionWithName:@"INVALID_REGION_CODE"
+ reason:[NSString stringWithFormat:@"Invalid region code:%@", regionCode]
+ userInfo:nil];
+ @throw metaException;
+ }
+ return metadata.countryCode;
+}
+
+
+/**
+ * Returns the national dialling prefix for a specific region. For example, this
+ * would be 1 for the United States, and 0 for New Zealand. Set stripNonDigits
+ * to NO to strip symbols like '~' (which indicates a wait for a dialling
+ * tone) from the prefix returned. If no national prefix is present, we return
+ * nil.
+ *
+ * <p>Warning: Do not use this method for do-your-own formatting - for some
+ * regions, the national dialling prefix is used only for certain types of
+ * numbers. Use the library's formatting functions to prefix the national prefix
+ * when required.
+ *
+ * @param {?string} regionCode the region that we want to get the dialling
+ * prefix for.
+ * @param {boolean} stripNonDigits NO to strip non-digits from the national
+ * dialling prefix.
+ * @return {?string} the dialling prefix for the region denoted by
+ * regionCode.
+ */
+- (NSString*)getNddPrefixForRegion:(NSString*)regionCode stripNonDigits:(BOOL)stripNonDigits
+{
+ NBPhoneMetaData *metadata = [self getMetadataForRegion:regionCode];
+ if (metadata == nil)
+ {
+ return nil;
+ }
+
+ NSString *nationalPrefix = metadata.nationalPrefix;
+ // If no national prefix was found, we return nil.
+ if (nationalPrefix.length == 0)
+ {
+ return nil;
+ }
+
+ if (stripNonDigits)
+ {
+ // Note: if any other non-numeric symbols are ever used in national
+ // prefixes, these would have to be removed here as well.
+ nationalPrefix = [nationalPrefix stringByReplacingOccurrencesOfString:@"~" withString:@""];
+ }
+ return nationalPrefix;
+}
+
+
+/**
+ * Checks if this is a region under the North American Numbering Plan
+ * Administration (NANPA).
+ *
+ * @param {?string} regionCode the ISO 3166-1 two-letter region code.
+ * @return {boolean} NO if regionCode is one of the regions under NANPA.
+ */
+- (BOOL)isNANPACountry:(NSString*)regionCode
+{
+ BOOL isExists = NO;
+
+ NSArray *res = [self regionCodeFromCountryCode:@(NANPA_COUNTRY_CODE_)];
+ for (NSString *inRegionCode in res)
+ {
+ if ([inRegionCode isEqualToString:regionCode.uppercaseString])
+ {
+ isExists = YES;
+ }
+ }
+
+ return regionCode != nil && isExists;
+}
+
+
+/**
+ * Checks whether countryCode represents the country calling code from a region
+ * whose national significant number could contain a leading zero. An example of
+ * such a region is Italy. Returns NO if no metadata for the country is
+ * found.
+ *
+ * @param {number} countryCallingCode the country calling code.
+ * @return {boolean}
+ */
+- (BOOL)isLeadingZeroPossible:(NSNumber*)countryCallingCode
+{
+ NBPhoneMetaData *mainMetadataForCallingCode = [self getMetadataForRegionOrCallingCode:countryCallingCode
+ regionCode:[self getRegionCodeForCountryCode:countryCallingCode]];
+
+ return mainMetadataForCallingCode != nil && mainMetadataForCallingCode.leadingZeroPossible;
+}
+
+
+/**
+ * Checks if the number is a valid vanity (alpha) number such as 800 MICROSOFT.
+ * A valid vanity number will start with at least 3 digits and will have three
+ * or more alpha characters. This does not do region-specific checks - to work
+ * out if this number is actually valid for a region, it should be parsed and
+ * methods such as {@link #isPossibleNumberWithReason} and
+ * {@link #isValidNumber} should be used.
+ *
+ * @param {string} number the number that needs to be checked.
+ * @return {boolean} NO if the number is a valid vanity number.
+ */
+- (BOOL)isAlphaNumber:(NSString*)number
+{
+ if ([self isViablePhoneNumber:number] == NO)
+ {
+ // Number is too short, or doesn't match the basic phone number pattern.
+ return NO;
+ }
+
+ /** @type {!goog.string.StringBuffer} */
+ NSString *strippedNumber = [number copy];
+ [self maybeStripExtension:&strippedNumber];
+
+ return [self matchesEntirely:VALID_ALPHA_PHONE_PATTERN_STRING string:strippedNumber];
+}
+
+
+/**
+ * Convenience wrapper around {@link #isPossibleNumberWithReason}. Instead of
+ * returning the reason for failure, this method returns a boolean value.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the number that needs to be
+ * checked.
+ * @return {boolean} NO if the number is possible.
+ */
+- (BOOL)isPossibleNumber:(NBPhoneNumber*)number error:(NSError**)error
+{
+ BOOL res = NO;
+ @try {
+ res = [self isPossibleNumber:number];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (BOOL)isPossibleNumber:(NBPhoneNumber*)number
+{
+ return [self isPossibleNumberWithReason:number] == NBEValidationResultIS_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.
+ *
+ * @param {string} numberPattern
+ * @param {string} number
+ * @return {ValidationResult}
+ * @private
+ */
+- (NBEValidationResult)testNumberLengthAgainstPattern:(NSString*)numberPattern number:(NSString*)number
+{
+ if ([self matchesEntirely:numberPattern string:number])
+ {
+ return NBEValidationResultIS_POSSIBLE;
+ }
+
+ if ([self stringPositionByRegex:number regex:numberPattern] == 0)
+ {
+ return NBEValidationResultTOO_LONG;
+ }
+ else
+ {
+ return NBEValidationResultTOO_SHORT;
+ }
+}
+
+
+/**
+ * Check whether a phone number is a possible number. It provides a more lenient
+ * check than {@link #isValidNumber} in the following sense:
+ * <ol>
+ * <li>It only checks the length of phone numbers. In particular, it doesn't
+ * check starting digits of the number.
+ * <li>It doesn't attempt to figure out the type of the number, but uses general
+ * rules which applies to all types of phone numbers in a region. Therefore, it
+ * is much faster than isValidNumber.
+ * <li>For fixed line numbers, many regions have the concept of area code, which
+ * together with subscriber number constitute the national significant number.
+ * It is sometimes okay to dial the subscriber number only when dialing in the
+ * same area. This function will return NO if the subscriber-number-only
+ * version is passed in. On the other hand, because isValidNumber validates
+ * using information on both starting digits (for fixed line numbers, that would
+ * most likely be area codes) and length (obviously includes the length of area
+ * codes for fixed line numbers), it will return NO for the
+ * subscriber-number-only version.
+ * </ol>
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the number that needs to be
+ * checked.
+ * @return {ValidationResult} a
+ * ValidationResult object which indicates whether the number is possible.
+ */
+- (NBEValidationResult)isPossibleNumberWithReason:(NBPhoneNumber*)number error:(NSError *__autoreleasing *)error
+{
+ NBEValidationResult res = -1;
+ @try {
+ res = [self isPossibleNumberWithReason:number];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+
+ return res;
+}
+
+
+- (NBEValidationResult)isPossibleNumberWithReason:(NBPhoneNumber*)number
+{
+ NSString *nationalNumber = [self getNationalSignificantNumber:number];
+ NSNumber *countryCode = number.countryCode;
+ // Note: For Russian Fed and NANPA numbers, we just use the rules from the
+ // default region (US or Russia) since the getRegionCodeForNumber will not
+ // work if the number is possible but not valid. This would need to be
+ // revisited if the possible number pattern ever differed between various
+ // regions within those plans.
+ if ([self hasValidCountryCallingCode:countryCode] == NO)
+ {
+ return NBEValidationResultINVALID_COUNTRY_CODE;
+ }
+
+ NSString *regionCode = [self getRegionCodeForCountryCode:countryCode];
+ // Metadata cannot be nil because the country calling code is valid.
+ NBPhoneMetaData *metadata = [self getMetadataForRegionOrCallingCode:countryCode regionCode:regionCode];
+ NBPhoneNumberDesc *generalNumDesc = metadata.generalDesc;
+
+ // Handling case of numbers with no metadata.
+ if ([self hasValue:generalNumDesc.nationalNumberPattern] == NO)
+ {
+ NSUInteger numberLength = nationalNumber.length;
+
+ if (numberLength < MIN_LENGTH_FOR_NSN_)
+ {
+ return NBEValidationResultTOO_SHORT;
+ }
+ else if (numberLength > MAX_LENGTH_FOR_NSN_)
+ {
+ return NBEValidationResultTOO_LONG;
+ }
+ else
+ {
+ return NBEValidationResultIS_POSSIBLE;
+ }
+ }
+
+ NSString *possibleNumberPattern = generalNumDesc.possibleNumberPattern;
+ return [self testNumberLengthAgainstPattern:possibleNumberPattern number:nationalNumber];
+}
+
+
+/**
+ * Check whether a phone number is a possible number given a number in the form
+ * of a string, and the region where the number could be dialed from. It
+ * provides a more lenient check than {@link #isValidNumber}. See
+ * {@link #isPossibleNumber} for details.
+ *
+ * <p>This method first parses the number, then invokes
+ * {@link #isPossibleNumber} with the resultant PhoneNumber object.
+ *
+ * @param {string} number the number that needs to be checked, in the form of a
+ * string.
+ * @param {string} regionDialingFrom the region that we are expecting the number
+ * to be dialed from.
+ * Note this is different from the region where the number belongs.
+ * For example, the number +1 650 253 0000 is a number that belongs to US.
+ * When written in this form, it can be dialed from any region. When it is
+ * 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 {boolean} NO if the number is possible.
+ */
+- (BOOL)isPossibleNumberString:(NSString*)number regionDialingFrom:(NSString*)regionDialingFrom error:(NSError**)error
+{
+ BOOL res = NO;
+ @try {
+ res = [self isPossibleNumberString:number regionDialingFrom:regionDialingFrom];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (BOOL)isPossibleNumberString:(NSString*)number regionDialingFrom:(NSString*)regionDialingFrom
+{
+ @try {
+ return [self isPossibleNumber:[self parse:number defaultRegion:regionDialingFrom]];
+ }
+ @catch (NSException *e) {
+ return NO;
+ }
+}
+
+
+/**
+ * Attempts to extract a valid number from a phone number that is too long to be
+ * valid, and resets the PhoneNumber object passed in to that valid version. If
+ * no valid number could be extracted, the PhoneNumber object passed in will not
+ * be modified.
+ * @param {i18n.phonenumbers.PhoneNumber} number a PhoneNumber object which
+ * contains a number that is too long to be valid.
+ * @return {boolean} NO if a valid phone number can be successfully extracted.
+ */
+- (BOOL)truncateTooLongNumber:(NBPhoneNumber*)number error:(NSError**)error
+{
+ BOOL res = NO;
+ @try {
+ res = [self truncateTooLongNumber:number];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (BOOL)truncateTooLongNumber:(NBPhoneNumber*)number
+{
+ if ([self isValidNumber:number])
+ {
+ return YES;
+ }
+
+ NBPhoneNumber *numberCopy = [number copy];
+ NSNumber *nationalNumber = number.nationalNumber;
+ do {
+ nationalNumber = [NSNumber numberWithLongLong:(long long)floor(nationalNumber.unsignedLongLongValue / 10)];
+ numberCopy.nationalNumber = [nationalNumber copy];
+ if ([nationalNumber isEqualToNumber:@0] || [self isPossibleNumberWithReason:numberCopy] == NBEValidationResultTOO_SHORT) {
+ return NO;
+ }
+ }
+ while ([self isValidNumber:numberCopy] == NO);
+
+ number.nationalNumber = nationalNumber;
+ return YES;
+}
+
+
+/**
+ * Extracts country calling code from fullNumber, returns it and places the
+ * remaining number in nationalNumber. It assumes that the leading plus sign or
+ * IDD has already been removed. Returns 0 if fullNumber doesn't start with a
+ * valid country calling code, and leaves nationalNumber unmodified.
+ *
+ * @param {!goog.string.StringBuffer} fullNumber
+ * @param {!goog.string.StringBuffer} nationalNumber
+ * @return {number}
+ */
+- (NSNumber*)extractCountryCode:(NSString*)fullNumber nationalNumber:(NSString**)nationalNumber
+{
+ if ((fullNumber.length == 0) || ([[fullNumber substringToIndex:1] isEqualToString:@"0"]))
+ {
+ // Country codes do not begin with a '0'.
+ return @0;
+ }
+
+ NSUInteger numberLength = fullNumber.length;
+
+ for (NSUInteger i = 1; i <= MAX_LENGTH_COUNTRY_CODE_ && i <= numberLength; ++i)
+ {
+ NSString *subNumber = [fullNumber substringWithRange:NSMakeRange(0, i)];
+ NSNumber *potentialCountryCode = [NSNumber numberWithInteger:[subNumber integerValue]];
+
+ NSArray *regionCodes = [self regionCodeFromCountryCode:potentialCountryCode];
+ if (regionCodes != nil && regionCodes.count > 0)
+ {
+ if (nationalNumber != NULL)
+ {
+ if ((*nationalNumber) == nil)
+ (*nationalNumber) = [NSString stringWithFormat:@"%@", [fullNumber substringFromIndex:i]];
+ else
+ (*nationalNumber) = [NSString stringWithFormat:@"%@%@", (*nationalNumber), [fullNumber substringFromIndex:i]];
+ }
+ return potentialCountryCode;
+ }
+ }
+
+ return @0;
+}
+
+
+/**
+ * Tries to extract a country calling code from a number. This method will
+ * return zero if no country calling code is considered to be present. Country
+ * calling codes are extracted in the following ways:
+ * <ul>
+ * <li>by stripping the international dialing prefix of the region the person is
+ * dialing from, if this is present in the number, and looking at the next
+ * digits
+ * <li>by stripping the '+' sign if present and then looking at the next digits
+ * <li>by comparing the start of the number and the country calling code of the
+ * default region. If the number is not considered possible for the numbering
+ * plan of the default region initially, but starts with the country calling
+ * code of this region, validation will be reattempted after stripping this
+ * country calling code. If this number is considered a possible number, then
+ * the first digits will be considered the country calling code and removed as
+ * such.
+ * </ul>
+ *
+ * It will throw a i18n.phonenumbers.Error if the number starts with a '+' but
+ * the country calling code supplied after this does not match that of any known
+ * region.
+ *
+ * @param {string} number non-normalized telephone number that we wish to
+ * extract a country calling code from - may begin with '+'.
+ * @param {i18n.phonenumbers.PhoneMetadata} defaultRegionMetadata metadata
+ * about the region this number may be from.
+ * @param {!goog.string.StringBuffer} nationalNumber a string buffer to store
+ * the national significant number in, in the case that a country calling
+ * code was extracted. The number is appended to any existing contents. If
+ * no country calling code was extracted, this will be left unchanged.
+ * @param {boolean} keepRawInput NO if the country_code_source and
+ * preferred_carrier_code fields of phoneNumber should be populated.
+ * @param {i18n.phonenumbers.PhoneNumber} phoneNumber the PhoneNumber object
+ * where the country_code and country_code_source need to be populated.
+ * Note the country_code is always populated, whereas country_code_source is
+ * only populated when keepCountryCodeSource is NO.
+ * @return {number} the country calling code extracted or 0 if none could be
+ * extracted.
+ * @throws {i18n.phonenumbers.Error}
+ */
+- (NSNumber*)maybeExtractCountryCode:(NSString*)number metadata:(NBPhoneMetaData*)defaultRegionMetadata
+ nationalNumber:(NSString**)nationalNumber keepRawInput:(BOOL)keepRawInput
+ phoneNumber:(NBPhoneNumber**)phoneNumber error:(NSError**)error
+{
+ if (nationalNumber == NULL || phoneNumber == NULL)
+ {
+ return @0;
+ }
+
+ NSNumber *res = @0;
+ @try {
+ res = [self maybeExtractCountryCode:number metadata:defaultRegionMetadata
+ nationalNumber:nationalNumber keepRawInput:keepRawInput phoneNumber:phoneNumber];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+
+ return res;
+}
+
+- (NSNumber*)maybeExtractCountryCode:(NSString*)number metadata:(NBPhoneMetaData*)defaultRegionMetadata
+ nationalNumber:(NSString**)nationalNumber keepRawInput:(BOOL)keepRawInput
+ phoneNumber:(NBPhoneNumber**)phoneNumber
+{
+ if (nationalNumber == NULL || phoneNumber == NULL || number.length <= 0)
+ {
+ return @0;
+ }
+
+ NSString *fullNumber = [number copy];
+ // Set the default prefix to be something that will never match.
+ NSString *possibleCountryIddPrefix = @"";
+ if (defaultRegionMetadata != nil)
+ {
+ possibleCountryIddPrefix = defaultRegionMetadata.internationalPrefix;
+ }
+
+ if (possibleCountryIddPrefix == nil)
+ {
+ possibleCountryIddPrefix = @"NonMatch";
+ }
+
+ /** @type {i18n.phonenumbers.PhoneNumber.CountryCodeSource} */
+ NBECountryCodeSource countryCodeSource = [self maybeStripInternationalPrefixAndNormalize:&fullNumber
+ possibleIddPrefix:possibleCountryIddPrefix];
+
+ if (keepRawInput)
+ {
+ (*phoneNumber).countryCodeSource = [NSNumber numberWithInt:countryCodeSource];
+ }
+
+ if (countryCodeSource != NBECountryCodeSourceFROM_DEFAULT_COUNTRY)
+ {
+ if (fullNumber.length <= MIN_LENGTH_FOR_NSN_)
+ {
+ @throw [NSException exceptionWithName:@"TOO_SHORT_AFTER_IDD"
+ reason:[NSString stringWithFormat:@"TOO_SHORT_AFTER_IDD:%@", fullNumber]
+ userInfo:nil];
+ }
+
+ NSNumber *potentialCountryCode = [self extractCountryCode:fullNumber nationalNumber:nationalNumber];
+
+ if (![potentialCountryCode isEqualToNumber:@0])
+ {
+ (*phoneNumber).countryCode = potentialCountryCode;
+ return potentialCountryCode;
+ }
+
+ // If this fails, they must be using a strange country calling code that we
+ // don't recognize, or that doesn't exist.
+ @throw [NSException exceptionWithName:@"INVALID_COUNTRY_CODE"
+ reason:[NSString stringWithFormat:@"INVALID_COUNTRY_CODE:%@", potentialCountryCode]
+ userInfo:nil];
+ }
+ else if (defaultRegionMetadata != nil)
+ {
+ // 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.
+ NSNumber *defaultCountryCode = defaultRegionMetadata.countryCode;
+ NSString *defaultCountryCodeString = [NSString stringWithFormat:@"%@", defaultCountryCode];
+ NSString *normalizedNumber = [fullNumber copy];
+
+ if ([normalizedNumber hasPrefix:defaultCountryCodeString])
+ {
+ NSString *potentialNationalNumber = [normalizedNumber substringFromIndex:defaultCountryCodeString.length];
+ NBPhoneNumberDesc *generalDesc = defaultRegionMetadata.generalDesc;
+
+ NSString *validNumberPattern = generalDesc.nationalNumberPattern;
+ // Passing null since we don't need the carrier code.
+ [self maybeStripNationalPrefixAndCarrierCode:&potentialNationalNumber metadata:defaultRegionMetadata carrierCode:nil];
+
+ NSString *potentialNationalNumberStr = [potentialNationalNumber copy];
+ NSString *possibleNumberPattern = generalDesc.possibleNumberPattern;
+ // 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 calling code
+ // stripped to be a better result and keep that instead.
+ if ((![self matchesEntirely:validNumberPattern string:fullNumber] &&
+ [self matchesEntirely:validNumberPattern string:potentialNationalNumberStr]) ||
+ [self testNumberLengthAgainstPattern:possibleNumberPattern number:fullNumber] == NBEValidationResultTOO_LONG)
+ {
+ (*nationalNumber) = [(*nationalNumber) stringByAppendingString:potentialNationalNumberStr];
+ if (keepRawInput)
+ {
+ (*phoneNumber).countryCodeSource = [NSNumber numberWithInt:NBECountryCodeSourceFROM_NUMBER_WITHOUT_PLUS_SIGN];
+ }
+ (*phoneNumber).countryCode = defaultCountryCode;
+ return defaultCountryCode;
+ }
+ }
+ }
+ // No country calling code present.
+ (*phoneNumber).countryCode = @0;
+ return @0;
+}
+
+
+/**
+ * Strips the IDD from the start of the number if present. Helper function used
+ * by maybeStripInternationalPrefixAndNormalize.
+ *
+ * @param {!RegExp} iddPattern the regular expression for the international
+ * prefix.
+ * @param {!goog.string.StringBuffer} number the phone number that we wish to
+ * strip any international dialing prefix from.
+ * @return {boolean} NO if an international prefix was present.
+ * @private
+ */
+- (BOOL)parsePrefixAsIdd:(NSString*)iddPattern sourceString:(NSString**)number
+{
+ if (number == NULL)
+ {
+ return NO;
+ }
+
+ NSString *numberStr = [(*number) copy];
+
+ if ([self stringPositionByRegex:numberStr regex:iddPattern] == 0)
+ {
+ NSTextCheckingResult *matched = [[self matchesByRegex:numberStr regex:iddPattern] objectAtIndex:0];
+ NSString *matchedString = [numberStr substringWithRange:matched.range];
+ NSUInteger matchEnd = matchedString.length;
+ NSString *remainString = [numberStr substringFromIndex:matchEnd];
+
+ NSRegularExpression *currentPattern = self.CAPTURING_DIGIT_PATTERN;
+ NSArray *matchedGroups = [currentPattern matchesInString:remainString options:0 range:NSMakeRange(0, remainString.length)];
+
+ if (matchedGroups && [matchedGroups count] > 0 && [matchedGroups objectAtIndex:0] != nil)
+ {
+ NSString *digitMatched = [remainString substringWithRange:((NSTextCheckingResult*)[matchedGroups objectAtIndex:0]).range];
+ if (digitMatched.length > 0)
+ {
+ NSString *normalizedGroup = [self normalizeDigitsOnly:digitMatched];
+ if ([normalizedGroup isEqualToString:@"0"]) {
+ return NO;
+ }
+ }
+ }
+
+ (*number) = [remainString copy];
+ return YES;
+ }
+
+ return NO;
+}
+
+
+/**
+ * Strips any international prefix (such as +, 00, 011) present in the number
+ * provided, normalizes the resulting number, and indicates if an international
+ * prefix was present.
+ *
+ * @param {!goog.string.StringBuffer} number the non-normalized telephone number
+ * that we wish to strip any international dialing prefix from.
+ * @param {string} possibleIddPrefix the international direct dialing prefix
+ * from the region we think this number may be dialed in.
+ * @return {CountryCodeSource} 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.
+ */
+- (NBECountryCodeSource)maybeStripInternationalPrefixAndNormalize:(NSString**)numberStr possibleIddPrefix:(NSString*)possibleIddPrefix error:(NSError**)error
+{
+ if (numberStr == NULL)
+ {
+ return 0;
+ }
+
+ NBECountryCodeSource res = 0;
+ @try {
+ res = [self maybeStripInternationalPrefixAndNormalize:numberStr possibleIddPrefix:possibleIddPrefix];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+- (NBECountryCodeSource)maybeStripInternationalPrefixAndNormalize:(NSString**)numberStr possibleIddPrefix:(NSString*)possibleIddPrefix
+{
+ if (numberStr == NULL || (*numberStr).length == 0)
+ {
+ return NBECountryCodeSourceFROM_DEFAULT_COUNTRY;
+ }
+
+ // Check to see if the number begins with one or more plus signs.
+ if ([self isStartingStringByRegex:(*numberStr) regex:self.LEADING_PLUS_CHARS_PATTERN_])
+ {
+ (*numberStr) = [self replaceStringByRegex:(*numberStr) regex:self.LEADING_PLUS_CHARS_PATTERN_ withTemplate:@""];
+ // Can now normalize the rest of the number since we've consumed the '+'
+ // sign at the start.
+ (*numberStr) = [self normalizePhoneNumber:(*numberStr)];
+ return NBECountryCodeSourceFROM_NUMBER_WITH_PLUS_SIGN;
+ }
+
+ // Attempt to parse the first digits as an international prefix.
+ NSString *iddPattern = [possibleIddPrefix copy];
+ [self normalizeSB:numberStr];
+
+ return [self parsePrefixAsIdd:iddPattern sourceString:numberStr] ? NBECountryCodeSourceFROM_NUMBER_WITH_IDD : NBECountryCodeSourceFROM_DEFAULT_COUNTRY;
+}
+
+
+/**
+ * Strips any national prefix (such as 0, 1) present in the number provided.
+ *
+ * @param {!goog.string.StringBuffer} number the normalized telephone number
+ * that we wish to strip any national dialing prefix from.
+ * @param {i18n.phonenumbers.PhoneMetadata} metadata the metadata for the
+ * region that we think this number is from.
+ * @param {goog.string.StringBuffer} carrierCode a place to insert the carrier
+ * code if one is extracted.
+ * @return {boolean} NO if a national prefix or carrier code (or both) could
+ * be extracted.
+ */
+- (BOOL)maybeStripNationalPrefixAndCarrierCode:(NSString**)number metadata:(NBPhoneMetaData*)metadata carrierCode:(NSString**)carrierCode error:(NSError**)error
+{
+ if (number == NULL)
+ {
+ return NO;
+ }
+
+ BOOL res = NO;
+ @try {
+ res = [self maybeStripNationalPrefixAndCarrierCode:number metadata:metadata carrierCode:carrierCode];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+
+- (BOOL)maybeStripNationalPrefixAndCarrierCode:(NSString**)number metadata:(NBPhoneMetaData*)metadata carrierCode:(NSString**)carrierCode
+{
+ if (number == NULL)
+ {
+ return NO;
+ }
+
+ NSString *numberStr = [(*number) copy];
+ NSUInteger numberLength = numberStr.length;
+ NSString *possibleNationalPrefix = metadata.nationalPrefixForParsing;
+
+ if (numberLength == 0 || [self hasValue:possibleNationalPrefix] == NO)
+ {
+ // Early return for numbers of zero length.
+ return NO;
+ }
+
+ // Attempt to parse the first digits as a national prefix.
+ NSString *prefixPattern = [NSString stringWithFormat:@"^(?:%@)", possibleNationalPrefix];
+ NSError *error = nil;
+ NSRegularExpression *currentPattern = [NSRegularExpression regularExpressionWithPattern:prefixPattern
+ options:0 error:&error];
+
+ NSArray *prefixMatcher = [currentPattern matchesInString:numberStr options:0 range:NSMakeRange(0, numberLength)];
+ if (prefixMatcher && [prefixMatcher count] > 0)
+ {
+ NSString *nationalNumberRule = metadata.generalDesc.nationalNumberPattern;
+ NSTextCheckingResult *firstMatch = [prefixMatcher objectAtIndex:0];
+ NSString *firstMatchString = [numberStr substringWithRange:firstMatch.range];
+
+ // prefixMatcher[numOfGroups] == null implies nothing was captured by the
+ // capturing groups in possibleNationalPrefix; therefore, no transformation
+ // is necessary, and we just remove the national prefix.
+ NSUInteger numOfGroups = firstMatch.numberOfRanges - 1;
+ NSString *transformRule = metadata.nationalPrefixTransformRule;
+ NSString *transformedNumber = @"";
+ NSRange firstRange = [firstMatch rangeAtIndex:numOfGroups];
+ NSString *firstMatchStringWithGroup = (firstRange.location != NSNotFound && firstRange.location < numberStr.length) ? [numberStr substringWithRange:firstRange] : nil;
+ BOOL noTransform = (transformRule == nil || transformRule.length == 0 || [self hasValue:firstMatchStringWithGroup] == NO);
+
+ if (noTransform)
+ {
+ transformedNumber = [numberStr substringFromIndex:firstMatchString.length];
+ }
+ else
+ {
+ transformedNumber = [self replaceFirstStringByRegex:numberStr regex:prefixPattern withTemplate:transformRule];
+ }
+ // If the original number was viable, and the resultant number is not,
+ // we return.
+ if ([self hasValue:nationalNumberRule ] && [self matchesEntirely:nationalNumberRule string:numberStr] &&
+ [self matchesEntirely:nationalNumberRule string:transformedNumber] == NO)
+ {
+ return NO;
+ }
+
+ if ((noTransform && numOfGroups > 0 && [self hasValue:firstMatchStringWithGroup]) || (!noTransform && numOfGroups > 1))
+ {
+ if (carrierCode != NULL && (*carrierCode) != nil)
+ {
+ (*carrierCode) = [(*carrierCode) stringByAppendingString:firstMatchStringWithGroup];
+ }
+ }
+ else if ((noTransform && numOfGroups > 0 && [self hasValue:firstMatchString]) || (!noTransform && numOfGroups > 1))
+ {
+ if (carrierCode != NULL && (*carrierCode) != nil)
+ {
+ (*carrierCode) = [(*carrierCode) stringByAppendingString:firstMatchString];
+ }
+ }
+
+ (*number) = transformedNumber;
+ return YES;
+ }
+ return NO;
+}
+
+
+/**
+ * Strips any extension (as in, the part of the number dialled after the call is
+ * connected, usually indicated with extn, ext, x or similar) from the end of
+ * the number, and returns it.
+ *
+ * @param {!goog.string.StringBuffer} number the non-normalized telephone number
+ * that we wish to strip the extension from.
+ * @return {string} the phone extension.
+ */
+- (NSString*)maybeStripExtension:(NSString**)number
+{
+ if (number == NULL)
+ {
+ return @"";
+ }
+
+ NSString *numberStr = [(*number) copy];
+ NSInteger mStart = [self stringPositionByRegex:numberStr regex:self.EXTN_PATTERN_];
+
+ // If we find a potential extension, and the number preceding this is a viable
+ // number, we assume it is an extension.
+ if (mStart >= 0 && [self isViablePhoneNumber:[numberStr substringWithRange:NSMakeRange(0, mStart)]])
+ {
+ // The numbers are captured into groups in the regular expression.
+ NSTextCheckingResult *firstMatch = [self matcheFirstByRegex:numberStr regex:self.EXTN_PATTERN_];
+ NSUInteger matchedGroupsLength = [firstMatch numberOfRanges];
+ for (NSUInteger i=1; i<matchedGroupsLength; i++)
+ {
+ NSRange curRange = [firstMatch rangeAtIndex:i];
+ if (curRange.location != NSNotFound && curRange.location < numberStr.length)
+ {
+ NSString *matchString = [(*number) substringWithRange:curRange];
+ // We go through the capturing groups until we find one that captured
+ // some digits. If none did, then we will return the empty string.
+ NSString *tokenedString = [numberStr substringWithRange:NSMakeRange(0, mStart)];
+ (*number) = @"";
+ (*number) = [(*number) stringByAppendingString:tokenedString];
+
+ return matchString;
+ }
+ }
+ }
+
+ return @"";
+}
+
+
+/**
+ * Checks to see that the region code used is valid, or if it is not valid, that
+ * the number to parse starts with a + symbol so that we can attempt to infer
+ * the region from the number.
+ * @param {string} numberToParse number that we are attempting to parse.
+ * @param {?string} defaultRegion region that we are expecting the number to be
+ * from.
+ * @return {boolean} NO if it cannot use the region provided and the region
+ * cannot be inferred.
+ * @private
+ */
+- (BOOL)checkRegionForParsing:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion
+{
+ // If the number is nil or empty, we can't infer the region.
+ return [self isValidRegionCode:defaultRegion] ||
+ (numberToParse != nil && numberToParse.length > 0 && [self isStartingStringByRegex:numberToParse regex:self.LEADING_PLUS_CHARS_PATTERN_]);
+}
+
+
+/**
+ * Parses a string and returns it in proto buffer format. This method will throw
+ * a {@link i18n.phonenumbers.Error} if the number is not considered to be a
+ * possible number. Note that validation of whether the number is actually a
+ * valid number for a particular region is not performed. This can be done
+ * separately with {@link #isValidNumber}.
+ *
+ * @param {?string} numberToParse number that we are attempting to parse. This
+ * can contain formatting such as +, ( and -, as well as a phone number
+ * extension. It can also be provided in RFC3966 format.
+ * @param {?string} defaultRegion region that we are expecting the number to be
+ * from. This is only used if the number being parsed is not written in
+ * international format. The country_code for the number in this case would
+ * be stored as that of the default region supplied. If the number is
+ * guaranteed to start with a '+' followed by the country calling code, then
+ * 'ZZ' or nil can be supplied.
+ * @return {i18n.phonenumbers.PhoneNumber} a phone number proto buffer filled
+ * with the parsed number.
+ * @throws {i18n.phonenumbers.Error} if the string is not considered to be a
+ * viable phone number or if no default region was supplied and the number
+ * is not in international format (does not start with +).
+ */
+- (NBPhoneNumber*)parse:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion
+{
+ return [self parseHelper:numberToParse defaultRegion:defaultRegion keepRawInput:NO checkRegion:YES];
+}
+
+
+- (NBPhoneNumber*)parse:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion error:(NSError**)error
+{
+ NBPhoneNumber *phoneNumber = nil;
+
+ @try {
+ phoneNumber = [self parseHelper:numberToParse defaultRegion:defaultRegion keepRawInput:NO checkRegion:YES];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+
+ return phoneNumber;
+}
+
+/**
+ * Parses a string using the phone's carrier region (when available, ZZ otherwise).
+ * This uses the country the sim card in the phone is registered with.
+ * For example if you have an AT&T sim card but are in Europe, this will parse the
+ * number using +1 (AT&T is a US Carrier) as the default country code.
+ * This also works for CDMA phones which don't have a sim card.
+ */
+- (NBPhoneNumber*)parseWithPhoneCarrierRegion:(NSString*)numberToParse error:(NSError**)error
+{
+ NSString *(^ISOCountryCodeByCarrier)() = ^() {
+ CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
+ CTCarrier *carrier = [networkInfo subscriberCellularProvider];
+ return [carrier isoCountryCode];
+ };
+ NSString *isoCode = ISOCountryCodeByCarrier();
+
+ if (!isoCode) {
+ isoCode = @"ZZ";
+ }
+
+ return [self parse:numberToParse defaultRegion:isoCode];
+}
+
+
+/**
+ * Parses a string and returns it in proto buffer format. This method differs
+ * from {@link #parse} in that it always populates the raw_input field of the
+ * protocol buffer with numberToParse as well as the country_code_source field.
+ *
+ * @param {string} numberToParse number that we are attempting to parse. This
+ * can contain formatting such as +, ( and -, as well as a phone number
+ * extension.
+ * @param {?string} defaultRegion region that we are expecting the number to be
+ * from. This is only used if the number being parsed is not written in
+ * international format. The country calling code for the number in this
+ * case would be stored as that of the default region supplied.
+ * @return {i18n.phonenumbers.PhoneNumber} a phone number proto buffer filled
+ * with the parsed number.
+ * @throws {i18n.phonenumbers.Error} if the string is not considered to be a
+ * viable phone number or if no default region was supplied.
+ */
+- (NBPhoneNumber*)parseAndKeepRawInput:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion error:(NSError**)error
+{
+ NBPhoneNumber *res = nil;
+ @try {
+ res = [self parseAndKeepRawInput:numberToParse defaultRegion:defaultRegion];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+- (NBPhoneNumber*)parseAndKeepRawInput:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion
+{
+ if ([self isValidRegionCode:defaultRegion] == NO)
+ {
+ if (numberToParse.length > 0 && [numberToParse hasPrefix:@"+"] == NO)
+ {
+ NSException* metaException = [NSException exceptionWithName:@"INVALID_COUNTRY_CODE"
+ reason:[NSString stringWithFormat:@"Invalid country code:%@", numberToParse]
+ userInfo:nil];
+ @throw metaException;
+ }
+ }
+ return [self parseHelper:numberToParse defaultRegion:defaultRegion keepRawInput:YES checkRegion:YES];
+}
+
+
+/**
+ * Parses a string and returns it in proto buffer format. This method is the
+ * same as the public {@link #parse} method, with the exception that it allows
+ * the default region to be nil, for use by {@link #isNumberMatch}.
+ *
+ * @param {?string} numberToParse number that we are attempting to parse. This
+ * can contain formatting such as +, ( and -, as well as a phone number
+ * extension.
+ * @param {?string} defaultRegion region that we are expecting the number to be
+ * from. This is only used if the number being parsed is not written in
+ * international format. The country calling code for the number in this
+ * case would be stored as that of the default region supplied.
+ * @param {boolean} keepRawInput whether to populate the raw_input field of the
+ * phoneNumber with numberToParse.
+ * @param {boolean} checkRegion should be set to NO if it is permitted for
+ * the default coregion to be nil or unknown ('ZZ').
+ * @return {i18n.phonenumbers.PhoneNumber} a phone number proto buffer filled
+ * with the parsed number.
+ * @throws {i18n.phonenumbers.Error}
+ * @private
+ */
+- (NBPhoneNumber*)parseHelper:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion
+ keepRawInput:(BOOL)keepRawInput checkRegion:(BOOL)checkRegion error:(NSError**)error
+{
+ NBPhoneNumber *res = nil;
+ @try {
+ res = [self parseHelper:numberToParse defaultRegion:defaultRegion keepRawInput:keepRawInput checkRegion:checkRegion];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+- (NBPhoneNumber*)parseHelper:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion
+ keepRawInput:(BOOL)keepRawInput checkRegion:(BOOL)checkRegion
+{
+ if (numberToParse == nil)
+ {
+ @throw [NSException exceptionWithName:@"NOT_A_NUMBER" reason:[NSString stringWithFormat:@"NOT_A_NUMBER:%@", numberToParse] userInfo:nil];
+ }
+ else if (numberToParse.length > MAX_INPUT_STRING_LENGTH_)
+ {
+ @throw [NSException exceptionWithName:@"TOO_LONG" reason:[NSString stringWithFormat:@"TOO_LONG:%@", numberToParse] userInfo:nil];
+ }
+
+ NSString *nationalNumber = @"";
+ [self buildNationalNumberForParsing:numberToParse nationalNumber:&nationalNumber];
+
+ if ([self isViablePhoneNumber:nationalNumber] == NO)
+ {
+ @throw [NSException exceptionWithName:@"NOT_A_NUMBER" reason:[NSString stringWithFormat:@"NOT_A_NUMBER:%@", nationalNumber] userInfo:nil];
+ }
+
+ // Check the region supplied is valid, or that the extracted number starts
+ // with some sort of + sign so the number's region can be determined.
+ if (checkRegion && [self checkRegionForParsing:nationalNumber defaultRegion:defaultRegion] == NO)
+ {
+ @throw [NSException exceptionWithName:@"INVALID_COUNTRY_CODE" reason:[NSString stringWithFormat:@"INVALID_COUNTRY_CODE:%@", defaultRegion] userInfo:nil];
+ }
+
+ NBPhoneNumber *phoneNumber = [[NBPhoneNumber alloc] init];
+ if (keepRawInput)
+ {
+ phoneNumber.rawInput = [numberToParse copy];
+ }
+ // Attempt to parse extension first, since it doesn't require region-specific
+ // data and we want to have the non-normalised number here.
+ NSString *extension = [self maybeStripExtension:&nationalNumber];
+ if (extension.length > 0)
+ {
+ phoneNumber.extension = [extension copy];
+ }
+
+ NBPhoneMetaData *regionMetadata = [self getMetadataForRegion:defaultRegion];
+ // Check to see if the number is given in international format so we know
+ // whether this number is from the default region or not.
+ NSString *normalizedNationalNumber = @"";
+ NSNumber *countryCode = @0;
+ NSString *nationalNumberStr = [nationalNumber copy];
+ @try {
+ countryCode = [self maybeExtractCountryCode:nationalNumberStr
+ metadata:regionMetadata
+ nationalNumber:&normalizedNationalNumber
+ keepRawInput:keepRawInput
+ phoneNumber:&phoneNumber];
+ }
+ @catch (NSException *e) {
+ if ([e.name isEqualToString:@"INVALID_COUNTRY_CODE"] && [self stringPositionByRegex:nationalNumberStr
+ regex:self.LEADING_PLUS_CHARS_PATTERN_] >= 0)
+ {
+ // Strip the plus-char, and try again.
+ nationalNumberStr = [self replaceStringByRegex:nationalNumberStr regex:self.LEADING_PLUS_CHARS_PATTERN_ withTemplate:@""];
+ countryCode = [self maybeExtractCountryCode:nationalNumberStr
+ metadata:regionMetadata
+ nationalNumber:&normalizedNationalNumber
+ keepRawInput:keepRawInput
+ phoneNumber:&phoneNumber];
+ if ([countryCode isEqualToNumber:@0])
+ {
+ @throw [NSException exceptionWithName:e.name
+ reason:[NSString stringWithFormat:@"%@:%@", e.name, nationalNumberStr]
+ userInfo:nil];
+ }
+ }
+ else
+ {
+ @throw e;
+ }
+ }
+
+ if (![countryCode isEqualToNumber:@0])
+ {
+ NSString *phoneNumberRegion = [self getRegionCodeForCountryCode:countryCode];
+ if (phoneNumberRegion != defaultRegion)
+ {
+ // Metadata cannot be nil because the country calling code is valid.
+ regionMetadata = [self getMetadataForRegionOrCallingCode:countryCode regionCode:phoneNumberRegion];
+ }
+ }
+ else
+ {
+ // If no extracted country calling code, use the region supplied instead.
+ // The national number is just the normalized version of the number we were
+ // given to parse.
+ [self normalizeSB:&nationalNumber];
+ normalizedNationalNumber = [normalizedNationalNumber stringByAppendingString:nationalNumber];
+
+ if (defaultRegion != nil)
+ {
+ countryCode = regionMetadata.countryCode;
+ phoneNumber.countryCode = countryCode;
+ }
+ else if (keepRawInput)
+ {
+ [phoneNumber clearCountryCodeSource];
+ }
+ }
+
+ if (normalizedNationalNumber.length < MIN_LENGTH_FOR_NSN_)
+ {
+ @throw [NSException exceptionWithName:@"TOO_SHORT_NSN"
+ reason:[NSString stringWithFormat:@"TOO_SHORT_NSN:%@", normalizedNationalNumber]
+ userInfo:nil];
+ }
+
+ if (regionMetadata != nil)
+ {
+ NSString *carrierCode = @"";
+ [self maybeStripNationalPrefixAndCarrierCode:&normalizedNationalNumber metadata:regionMetadata carrierCode:&carrierCode];
+
+ if (keepRawInput)
+ {
+ phoneNumber.PreferredDomesticCarrierCode = [carrierCode copy];
+ }
+ }
+
+ NSString *normalizedNationalNumberStr = [normalizedNationalNumber copy];
+
+ NSUInteger lengthOfNationalNumber = normalizedNationalNumberStr.length;
+ if (lengthOfNationalNumber < MIN_LENGTH_FOR_NSN_)
+ {
+ @throw [NSException exceptionWithName:@"TOO_SHORT_NSN"
+ reason:[NSString stringWithFormat:@"TOO_SHORT_NSN:%@", normalizedNationalNumberStr]
+ userInfo:nil];
+ }
+
+ if (lengthOfNationalNumber > MAX_LENGTH_FOR_NSN_)
+ {
+ @throw [NSException exceptionWithName:@"TOO_LONG"
+ reason:[NSString stringWithFormat:@"TOO_LONG:%@", normalizedNationalNumberStr]
+ userInfo:nil];
+ }
+
+ if ([normalizedNationalNumberStr hasPrefix:@"0"])
+ {
+ phoneNumber.italianLeadingZero = YES;
+ }
+
+ phoneNumber.nationalNumber = [NSNumber numberWithLongLong:(UInt64)[normalizedNationalNumberStr longLongValue]];
+ return phoneNumber;
+}
+
+
+/**
+ * Converts numberToParse to a form that we can parse and write it to
+ * nationalNumber if it is written in RFC3966; otherwise extract a possible
+ * number out of it and write to nationalNumber.
+ *
+ * @param {?string} numberToParse number that we are attempting to parse. This
+ * can contain formatting such as +, ( and -, as well as a phone number
+ * extension.
+ * @param {!goog.string.StringBuffer} nationalNumber a string buffer for storing
+ * the national significant number.
+ * @private
+ */
+- (void)buildNationalNumberForParsing:(NSString*)numberToParse nationalNumber:(NSString**)nationalNumber
+{
+ if (nationalNumber == NULL)
+ return;
+
+ NSInteger indexOfPhoneContext = [self indexOfStringByString:numberToParse target:RFC3966_PHONE_CONTEXT_];
+ if (indexOfPhoneContext > 0)
+ {
+ NSUInteger phoneContextStart = indexOfPhoneContext + RFC3966_PHONE_CONTEXT_.length;
+ // If the phone context contains a phone number prefix, we need to capture
+ // it, whereas domains will be ignored.
+ if ([numberToParse characterAtIndex:phoneContextStart] == '+')
+ {
+ // Additional parameters might follow the phone context. If so, we will
+ // remove them here because the parameters after phone context are not
+ // important for parsing the phone number.
+ NSRange foundRange = [numberToParse rangeOfString:@";" options:NSLiteralSearch range:NSMakeRange(phoneContextStart, numberToParse.length - phoneContextStart)];
+ if (foundRange.location != NSNotFound)
+ {
+ NSRange subRange = NSMakeRange(phoneContextStart, foundRange.location - phoneContextStart);
+ (*nationalNumber) = [(*nationalNumber) stringByAppendingString:[numberToParse substringWithRange:subRange]];
+ }
+ else
+ {
+ (*nationalNumber) = [(*nationalNumber) stringByAppendingString:[numberToParse substringFromIndex:phoneContextStart]];
+ }
+ }
+
+ // Now append everything between the "tel:" prefix and the phone-context.
+ // This should include the national number, an optional extension or
+ // isdn-subaddress component.
+ NSUInteger rfc3966Start = [self indexOfStringByString:numberToParse target:RFC3966_PREFIX_] + RFC3966_PREFIX_.length;
+ NSString *subString = [numberToParse substringWithRange:NSMakeRange(rfc3966Start, indexOfPhoneContext - rfc3966Start)];
+ (*nationalNumber) = [(*nationalNumber) stringByAppendingString:subString];
+ }
+ else
+ {
+ // Extract a possible number from the string passed in (this strips leading
+ // characters that could not be the start of a phone number.)
+ (*nationalNumber) = [(*nationalNumber) stringByAppendingString:[self extractPossibleNumber:numberToParse]];
+ }
+
+ // Delete the isdn-subaddress and everything after it if it is present.
+ // Note extension won't appear at the same time with isdn-subaddress
+ // according to paragraph 5.3 of the RFC3966 spec,
+ NSString *nationalNumberStr = [(*nationalNumber) copy];
+ NSInteger indexOfIsdn = [self indexOfStringByString:nationalNumberStr target:RFC3966_ISDN_SUBADDRESS_];
+ if (indexOfIsdn > 0)
+ {
+ (*nationalNumber) = @"";
+ (*nationalNumber) = [(*nationalNumber) stringByAppendingString:[nationalNumberStr substringWithRange:NSMakeRange(0, indexOfIsdn)]];
+ }
+ // If both phone context and isdn-subaddress are absent but other
+ // parameters are present, the parameters are left in nationalNumber. This
+ // is because we are concerned about deleting content from a potential
+ // number string when there is no strong evidence that the number is
+ // actually written in RFC3966.
+}
+
+
+/**
+ * Takes two phone numbers and compares them for equality.
+ *
+ * <p>Returns EXACT_MATCH if the country_code, NSN, presence of a leading zero
+ * for Italian numbers and any extension present are the same. Returns NSN_MATCH
+ * if either or both has no region specified, and the NSNs and extensions are
+ * the same. Returns SHORT_NSN_MATCH if either or both has no region specified,
+ * or the region specified is the same, and one NSN could be a shorter version
+ * of the other number. This includes the case where one has an extension
+ * specified, and the other does not. Returns NO_MATCH otherwise. For example,
+ * the numbers +1 345 657 1234 and 657 1234 are a SHORT_NSN_MATCH. The numbers
+ * +1 345 657 1234 and 345 657 are a NO_MATCH.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber|string} firstNumberIn first number to
+ * compare. If it is a string it can contain formatting, and can have
+ * country calling code specified with + at the start.
+ * @param {i18n.phonenumbers.PhoneNumber|string} secondNumberIn second number to
+ * compare. If it is a string it can contain formatting, and can have
+ * country calling code specified with + at the start.
+ * @return {MatchType} NOT_A_NUMBER, NO_MATCH,
+ * SHORT_NSN_MATCH, NSN_MATCH or EXACT_MATCH depending on the level of
+ * equality of the two numbers, described in the method definition.
+ */
+- (NBEMatchType)isNumberMatch:(id)firstNumberIn second:(id)secondNumberIn error:(NSError**)error
+{
+ NBEMatchType res = 0;
+ @try {
+ res = [self isNumberMatch:firstNumberIn second:secondNumberIn];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+- (NBEMatchType)isNumberMatch:(id)firstNumberIn second:(id)secondNumberIn
+{
+
+ // If the input arguements are strings parse them to a proto buffer format.
+ // Else make copies of the phone numbers so that the numbers passed in are not
+ // edited.
+ /** @type {i18n.phonenumbers.PhoneNumber} */
+ NBPhoneNumber *firstNumber = nil, *secondNumber = nil;
+ if ([firstNumberIn isKindOfClass:[NSString class]])
+ {
+ // First see if the first number has an implicit country calling code, by
+ // attempting to parse it.
+ @try {
+ firstNumber = [self parse:firstNumberIn defaultRegion:UNKNOWN_REGION_];
+ }
+ @catch (NSException *e) {
+ if ([e.name isEqualToString:@"INVALID_COUNTRY_CODE"] == NO)
+ {
+ return NBEMatchTypeNOT_A_NUMBER;
+ }
+ // The first number has no country calling code. EXACT_MATCH is no longer
+ // possible. We parse it as if the region was the same as that for the
+ // second number, and if EXACT_MATCH is returned, we replace this with
+ // NSN_MATCH.
+ if ([secondNumberIn isKindOfClass:[NSString class]] == NO)
+ {
+ NSString *secondNumberRegion = [self getRegionCodeForCountryCode:((NBPhoneNumber*)secondNumberIn).countryCode];
+ if (secondNumberRegion != UNKNOWN_REGION_)
+ {
+ @try {
+ firstNumber = [self parse:firstNumberIn defaultRegion:secondNumberRegion];
+ }
+ @catch (NSException *e2) {
+ return NBEMatchTypeNOT_A_NUMBER;
+ }
+
+ NBEMatchType match = [self isNumberMatch:firstNumber second:secondNumberIn];
+ if (match == NBEMatchTypeEXACT_MATCH)
+ {
+ return NBEMatchTypeNSN_MATCH;
+ }
+ return match;
+ }
+ }
+ // If the second number is a string or doesn't have a valid country
+ // calling code, we parse the first number without country calling code.
+ @try {
+ firstNumber = [self parseHelper:firstNumberIn defaultRegion:nil keepRawInput:NO checkRegion:NO];
+ }
+ @catch (NSException *e2) {
+ return NBEMatchTypeNOT_A_NUMBER;
+ }
+ }
+ }
+ else
+ {
+ firstNumber = [firstNumberIn copy];
+ }
+
+ if ([secondNumberIn isKindOfClass:[NSString class]])
+ {
+ @try {
+ secondNumber = [self parse:secondNumberIn defaultRegion:UNKNOWN_REGION_];
+ return [self isNumberMatch:firstNumberIn second:secondNumber];
+ }
+ @catch (NSException *e2) {
+ if ([e2.name isEqualToString:@"INVALID_COUNTRY_CODE"] == NO)
+ {
+ return NBEMatchTypeNOT_A_NUMBER;
+ }
+ return [self isNumberMatch:secondNumberIn second:firstNumber];
+ }
+ }
+ else
+ {
+ secondNumber = [secondNumberIn copy];
+ }
+
+ // First clear raw_input, country_code_source and
+ // preferred_domestic_carrier_code fields and any empty-string extensions so
+ // that we can use the proto-buffer equality method.
+ firstNumber.rawInput = @"";
+ [firstNumber clearCountryCodeSource];
+ firstNumber.PreferredDomesticCarrierCode = @"";
+
+ secondNumber.rawInput = @"";
+ [secondNumber clearCountryCodeSource];
+ secondNumber.PreferredDomesticCarrierCode = @"";
+
+ if (firstNumber.extension != nil && firstNumber.extension.length == 0)
+ {
+ firstNumber.extension = nil;
+ }
+
+ if (secondNumber.extension != nil && secondNumber.extension.length == 0)
+ {
+ secondNumber.extension = nil;
+ }
+
+ // Early exit if both had extensions and these are different.
+ if ([self hasValue:firstNumber.extension] && [self hasValue:secondNumber.extension] &&
+ [firstNumber.extension isEqualToString:secondNumber.extension] == NO)
+ {
+ return NBEMatchTypeNO_MATCH;
+ }
+
+ NSNumber *firstNumberCountryCode = firstNumber.countryCode;
+ NSNumber *secondNumberCountryCode = secondNumber.countryCode;
+
+ // Both had country_code specified.
+ if (![firstNumberCountryCode isEqualToNumber:@0] && ![secondNumberCountryCode isEqualToNumber:@0])
+ {
+ if ([firstNumber isEqual:secondNumber])
+ {
+ return NBEMatchTypeEXACT_MATCH;
+ }
+ else if ([firstNumberCountryCode isEqualToNumber:secondNumberCountryCode] && [self isNationalNumberSuffixOfTheOther:firstNumber second:secondNumber])
+ {
+ // A SHORT_NSN_MATCH occurs if there is a difference because of the
+ // presence or absence of an 'Italian leading zero', the presence or
+ // absence of an extension, or one NSN being a shorter variant of the
+ // other.
+ return NBEMatchTypeSHORT_NSN_MATCH;
+ }
+ // This is not a match.
+ return NBEMatchTypeNO_MATCH;
+ }
+ // Checks cases where one or both country_code fields were not specified. To
+ // make equality checks easier, we first set the country_code fields to be
+ // equal.
+ firstNumber.countryCode = @0;
+ secondNumber.countryCode = @0;
+ // If all else was the same, then this is an NSN_MATCH.
+ if ([firstNumber isEqual:secondNumber])
+ {
+ return NBEMatchTypeNSN_MATCH;
+ }
+
+ if ([self isNationalNumberSuffixOfTheOther:firstNumber second:secondNumber])
+ {
+ return NBEMatchTypeSHORT_NSN_MATCH;
+ }
+ return NBEMatchTypeNO_MATCH;
+}
+
+
+/**
+ * Returns NO when one national number is the suffix of the other or both are
+ * the same.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} firstNumber the first PhoneNumber
+ * object.
+ * @param {i18n.phonenumbers.PhoneNumber} secondNumber the second PhoneNumber
+ * object.
+ * @return {boolean} NO if one PhoneNumber is the suffix of the other one.
+ * @private
+ */
+- (BOOL)isNationalNumberSuffixOfTheOther:(NBPhoneNumber*)firstNumber second:(NBPhoneNumber*)secondNumber
+{
+ NSString *firstNumberNationalNumber = [NSString stringWithFormat:@"%@", firstNumber.nationalNumber];
+ NSString *secondNumberNationalNumber = [NSString stringWithFormat:@"%@", secondNumber.nationalNumber];
+
+ // Note that endsWith returns NO if the numbers are equal.
+ return [firstNumberNationalNumber hasSuffix:secondNumberNationalNumber] ||
+ [secondNumberNationalNumber hasSuffix:firstNumberNationalNumber];
+}
+
+
+/**
+ * Returns NO if the number can be dialled from outside the region, or
+ * unknown. If the number can only be dialled from within the region, returns
+ * NO. Does not check the number is a valid number.
+ * TODO: Make this method public when we have enough metadata to make it
+ * worthwhile. Currently visible for testing purposes only.
+ *
+ * @param {i18n.phonenumbers.PhoneNumber} number the phone-number for which we
+ * want to know whether it is diallable from outside the region.
+ * @return {boolean} NO if the number can only be dialled from within the
+ * country.
+ */
+- (BOOL)canBeInternationallyDialled:(NBPhoneNumber*)number error:(NSError**)error
+{
+ BOOL res = NO;
+ @try {
+ res = [self canBeInternationallyDialled:number];
+ }
+ @catch (NSException *exception) {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObject:exception.reason
+ forKey:NSLocalizedDescriptionKey];
+ if (error != NULL)
+ (*error) = [NSError errorWithDomain:exception.name code:0 userInfo:userInfo];
+ }
+ return res;
+}
+
+- (BOOL)canBeInternationallyDialled:(NBPhoneNumber*)number
+{
+ NBPhoneMetaData *metadata = [self getMetadataForRegion:[self getRegionCodeForNumber:number]];
+ if (metadata == nil)
+ {
+ // Note numbers belonging to non-geographical entities (e.g. +800 numbers)
+ // are always internationally diallable, and will be caught here.
+ return YES;
+ }
+ NSString *nationalSignificantNumber = [self getNationalSignificantNumber:number];
+ return [self isNumberMatchingDesc:nationalSignificantNumber numberDesc:metadata.noInternationalDialling] == NO;
+}
+
+
+/**
+ * Check whether the entire input sequence can be matched against the regular
+ * expression.
+ *
+ * @param {!RegExp|string} regex the regular expression to match against.
+ * @param {string} str the string to test.
+ * @return {boolean} NO if str can be matched entirely against regex.
+ * @private
+ */
+- (BOOL)matchesEntirely:(NSString*)regex string:(NSString*)str
+{
+ if ([regex rangeOfString:@"^"].location == NSNotFound)
+ {
+ regex = [NSString stringWithFormat:@"^(?:%@)$", regex];
+ }
+
+ NSError *error = nil;
+ NSRegularExpression *currentPattern = [NSRegularExpression regularExpressionWithPattern:regex options:0 error:&error];
+ NSTextCheckingResult *matchResult = [currentPattern firstMatchInString:str options:0 range:NSMakeRange(0, str.length)];
+
+ if (matchResult != nil)
+ {
+ NSString *founds = [str substringWithRange:matchResult.range];
+
+ if ([founds isEqualToString:str])
+ {
+ return YES;
+ }
+ }
+
+ return NO;
+}
+
+
+@end
diff --git a/libPhoneNumber/PhoneNumberMetaData.json b/libPhoneNumber/PhoneNumberMetaData.json
new file mode 100644
index 0000000..76c28f8
--- /dev/null
+++ b/libPhoneNumber/PhoneNumberMetaData.json
@@ -0,0 +1 @@
+{"countryCodeToRegionCodeMap":{"1":["US","AG","AI","AS","BB","BM","BS","CA","DM","DO","GD","GU","JM","KN","KY","LC","MP","MS","PR","SX","TC","TT","VC","VG","VI"],"7":["RU","KZ"],"20":["EG"],"27":["ZA"],"30":["GR"],"31":["NL"],"32":["BE"],"33":["FR"],"34":["ES"],"36":["HU"],"39":["IT"],"40":["RO"],"41":["CH"],"43":["AT"],"44":["GB","GG","IM","JE"],"45":["DK"],"46":["SE"],"47":["NO","SJ"],"48":["PL"],"49":["DE"],"51":["PE"],"52":["MX"],"53":["CU"],"54":["AR"],"55":["BR"],"56":["CL"],"57":["CO"],"58":["VE"],"60":["MY"],"61":["AU","CC","CX"],"62":["ID"],"63":["PH"],"64":["NZ"],"65":["SG"],"66":["TH"],"81":["JP"],"82":["KR"],"84":["VN"],"86":["CN"],"90":["TR"],"91":["IN"],"92":["PK"],"93":["AF"],"94":["LK"],"95":["MM"],"98":["IR"],"211":["SS"],"212":["MA","EH"],"213":["DZ"],"216":["TN"],"218":["LY"],"220":["GM"],"221":["SN"],"222":["MR"],"223":["ML"],"224":["GN"],"225":["CI"],"226":["BF"],"227":["NE"],"228":["TG"],"229":["BJ"],"230":["MU"],"231":["LR"],"232":["SL"],"233":["GH"],"234":["NG"],"235":["TD"],"236":["CF"],"237":["CM"],"238":["CV"],"239":["ST"],"240":["GQ"],"241":["GA"],"242":["CG"],"243":["CD"],"244":["AO"],"245":["GW"],"246":["IO"],"247":["AC"],"248":["SC"],"249":["SD"],"250":["RW"],"251":["ET"],"252":["SO"],"253":["DJ"],"254":["KE"],"255":["TZ"],"256":["UG"],"257":["BI"],"258":["MZ"],"260":["ZM"],"261":["MG"],"262":["RE","YT"],"263":["ZW"],"264":["NA"],"265":["MW"],"266":["LS"],"267":["BW"],"268":["SZ"],"269":["KM"],"290":["SH","TA"],"291":["ER"],"297":["AW"],"298":["FO"],"299":["GL"],"350":["GI"],"351":["PT"],"352":["LU"],"353":["IE"],"354":["IS"],"355":["AL"],"356":["MT"],"357":["CY"],"358":["FI","AX"],"359":["BG"],"370":["LT"],"371":["LV"],"372":["EE"],"373":["MD"],"374":["AM"],"375":["BY"],"376":["AD"],"377":["MC"],"378":["SM"],"379":["VA"],"380":["UA"],"381":["RS"],"382":["ME"],"385":["HR"],"386":["SI"],"387":["BA"],"389":["MK"],"420":["CZ"],"421":["SK"],"423":["LI"],"500":["FK"],"501":["BZ"],"502":["GT"],"503":["SV"],"504":["HN"],"505":["NI"],"506":["CR"],"507":["PA"],"508":["PM"],"509":["HT"],"590":["GP","BL","MF"],"591":["BO"],"592":["GY"],"593":["EC"],"594":["GF"],"595":["PY"],"596":["MQ"],"597":["SR"],"598":["UY"],"599":["CW","BQ"],"670":["TL"],"672":["NF"],"673":["BN"],"674":["NR"],"675":["PG"],"676":["TO"],"677":["SB"],"678":["VU"],"679":["FJ"],"680":["PW"],"681":["WF"],"682":["CK"],"683":["NU"],"685":["WS"],"686":["KI"],"687":["NC"],"688":["TV"],"689":["PF"],"690":["TK"],"691":["FM"],"692":["MH"],"800":["001"],"808":["001"],"850":["KP"],"852":["HK"],"853":["MO"],"855":["KH"],"856":["LA"],"870":["001"],"878":["001"],"880":["BD"],"881":["001"],"882":["001"],"883":["001"],"886":["TW"],"888":["001"],"960":["MV"],"961":["LB"],"962":["JO"],"963":["SY"],"964":["IQ"],"965":["KW"],"966":["SA"],"967":["YE"],"968":["OM"],"970":["PS"],"971":["AE"],"972":["IL"],"973":["BH"],"974":["QA"],"975":["BT"],"976":["MN"],"977":["NP"],"979":["001"],"992":["TJ"],"993":["TM"],"994":["AZ"],"995":["GE"],"996":["KG"],"998":["UZ"]},"countryToMetadata":{"800":[null,[null,null,"\\d{8}","\\d{8}",null,null,"12345678"],[null,null,"NA","NA",null,null,"12345678"],[null,null,"NA","NA",null,null,"12345678"],[null,null,"\\d{8}","\\d{8}",null,null,"12345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"001",800,"",null,null,null,null,null,null,1,[[null,"(\\d{4})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"NA","NA"],[null,null,"NA","NA"]],"808":[null,[null,null,"\\d{8}","\\d{8}",null,null,"12345678"],[null,null,"NA","NA",null,null,"12345678"],[null,null,"NA","NA",null,null,"12345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"\\d{8}","\\d{8}",null,null,"12345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],"001",808,"",null,null,null,null,null,null,1,[[null,"(\\d{4})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"NA","NA"],[null,null,"NA","NA"]],"870":[null,[null,null,"[35-7]\\d{8}","\\d{9}",null,null,"301234567"],[null,null,"NA","NA",null,null,"301234567"],[null,null,"(?:[356]\\d|7[6-8])\\d{7}","\\d{9}",null,null,"301234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"001",870,"",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"878":[null,[null,null,"1\\d{11}","\\d{12}",null,null,"101234567890"],[null,null,"NA","NA",null,null,"101234567890"],[null,null,"NA","NA",null,null,"101234567890"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"10\\d{10}","\\d{12}",null,null,"101234567890"],"001",878,"",null,null,null,null,null,null,1,[[null,"(\\d{2})(\\d{5})(\\d{5})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"881":[null,[null,null,"[67]\\d{8}","\\d{9}",null,null,"612345678"],[null,null,"NA","NA",null,null,"612345678"],[null,null,"[67]\\d{8}","\\d{9}",null,null,"612345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"001",881,"",null,null,null,null,null,null,null,[[null,"(\\d)(\\d{3})(\\d{5})","$1 $2 $3",["[67]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"882":[null,[null,null,"[13]\\d{6,11}","\\d{7,12}",null,null,"3451234567"],[null,null,"NA","NA",null,null,"3451234567"],[null,null,"3(?:2\\d{3}|37\\d{2}|4(?:2|7\\d{3}))\\d{4}","\\d{7,10}",null,null,"3451234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"1(?:3(?:0[0347]|[13][0139]|2[035]|4[013568]|6[0459]|7[06]|8[15678]|9[0689])\\d{4}|6\\d{5,10})|345\\d{7}","\\d{7,12}",null,null,"3451234567"],"001",882,"",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["3[23]"],"","",0],[null,"(\\d{2})(\\d{5})","$1 $2",["16|342"],"","",0],[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["34[57]"],"","",0],[null,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["348"],"","",0],[null,"(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["1"],"","",0],[null,"(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["16"],"","",0],[null,"(\\d{2})(\\d{4,5})(\\d{5})","$1 $2 $3",["16"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"348[57]\\d{7}","\\d{11}",null,null,"3451234567"]],"883":[null,[null,null,"51\\d{7}(?:\\d{3})?","\\d{9}(?:\\d{3})?",null,null,"510012345"],[null,null,"NA","NA",null,null,"510012345"],[null,null,"NA","NA",null,null,"510012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"51(?:00\\d{5}(?:\\d{3})?|10\\d{8})","\\d{9}(?:\\d{3})?",null,null,"510012345"],"001",883,"",null,null,null,null,null,null,1,[[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",null,"","",0],[null,"(\\d{3})(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"888":[null,[null,null,"\\d{11}","\\d{11}",null,null,"12345678901"],[null,null,"NA","NA",null,null,"12345678901"],[null,null,"NA","NA",null,null,"12345678901"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"001",888,"",null,null,null,null,null,null,1,[[null,"(\\d{3})(\\d{3})(\\d{5})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"\\d{11}","\\d{11}",null,null,"12345678901"],1,[null,null,"NA","NA"],[null,null,"NA","NA"]],"979":[null,[null,null,"\\d{9}","\\d{9}",null,null,"123456789"],[null,null,"NA","NA",null,null,"123456789"],[null,null,"NA","NA",null,null,"123456789"],[null,null,"NA","NA"],[null,null,"\\d{9}","\\d{9}",null,null,"123456789"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"001",979,"",null,null,null,null,null,null,1,[[null,"(\\d)(\\d{4})(\\d{4})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"NA","NA"],[null,null,"NA","NA"]],"AC":[null,[null,null,"[2-467]\\d{3}","\\d{4}"],[null,null,"(?:[267]\\d|3[0-5]|4[4-69])\\d{2}","\\d{4}",null,null,"6889"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AC",247,"00",null,null,null,null,null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"AD":[null,[null,null,"(?:[346-9]|180)\\d{5}","\\d{6,8}"],[null,null,"[78]\\d{5}","\\d{6}",null,null,"712345"],[null,null,"[346]\\d{5}","\\d{6}",null,null,"312345"],[null,null,"180[02]\\d{4}","\\d{8}",null,null,"18001234"],[null,null,"9\\d{5}","\\d{6}",null,null,"912345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AD",376,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{3})","$1 $2",["[346-9]"],"","",0],[null,"(180[02])(\\d{4})","$1 $2",["1"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[0268]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"AE":[null,[null,null,"[2-79]\\d{7,8}|800\\d{2,9}","\\d{5,12}"],[null,null,"[2-4679][2-8]\\d{6}","\\d{7,8}",null,null,"22345678"],[null,null,"5[0256]\\d{7}","\\d{9}",null,null,"501234567"],[null,null,"400\\d{6}|800\\d{2,9}","\\d{5,12}",null,null,"800123456"],[null,null,"900[02]\\d{5}","\\d{9}",null,null,"900234567"],[null,null,"700[05]\\d{5}","\\d{9}",null,null,"700012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AE",971,"00","0",null,null,"0",null,null,null,[[null,"([2-4679])(\\d{3})(\\d{4})","$1 $2 $3",["[2-4679][2-8]"],"0$1","",0],[null,"(5[0256])(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1","",0],[null,"([479]00)(\\d)(\\d{5})","$1 $2 $3",["[479]0"],"$1","",0],[null,"([68]00)(\\d{2,9})","$1 $2",["60|8"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"600[25]\\d{5}","\\d{9}",null,null,"600212345"],null,[null,null,"112|99[789]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"AF":[null,[null,null,"[2-7]\\d{8}","\\d{7,9}"],[null,null,"(?:[25][0-8]|[34][0-4]|6[0-5])[2-9]\\d{6}","\\d{7,9}",null,null,"234567890"],[null,null,"7[057-9]\\d{7}","\\d{9}",null,null,"701234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AF",93,"00","0",null,null,"0",null,null,null,[[null,"([2-7]\\d)(\\d{3})(\\d{4})","$1 $2 $3",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:02|19)","\\d{3}",null,null,"119"],[null,null,"NA","NA"]],"AG":[null,[null,null,"[2589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"268(?:4(?:6[0-38]|84)|56[0-2])\\d{4}","\\d{7}(?:\\d{3})?",null,null,"2684601234"],[null,null,"268(?:464|7(?:2[0-9]|64|7[0-689]|8[02-68]))\\d{4}","\\d{10}",null,null,"2684641234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"26848[01]\\d{4}","\\d{10}",null,null,"2684801234"],"AG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"26840[69]\\d{4}","\\d{10}",null,null,"2684061234"],null,"268",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"9(?:11|99)","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"AI":[null,[null,null,"[2589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"2644(?:6[12]|9[78])\\d{4}","\\d{7}(?:\\d{3})?",null,null,"2644612345"],[null,null,"264(?:235|476|5(?:3[6-9]|8[1-4])|7(?:29|72))\\d{4}","\\d{10}",null,null,"2642351234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"AI",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"264",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"AL":[null,[null,null,"[2-57]\\d{7}|6\\d{8}|8\\d{5,7}|9\\d{5}","\\d{5,9}"],[null,null,"(?:2(?:[168][1-9]|[247]\\d|9[1-7])|3(?:1[1-3]|[2-6]\\d|[79][1-8]|8[1-9])|4\\d{2}|5(?:1[1-4]|[2-578]\\d|6[1-5]|9[1-7])|8(?:[19][1-5]|[2-6]\\d|[78][1-7]))\\d{5}","\\d{5,8}",null,null,"22345678"],[null,null,"6[6-9]\\d{7}","\\d{9}",null,null,"661234567"],[null,null,"800\\d{4}","\\d{7}",null,null,"8001234"],[null,null,"900\\d{3}","\\d{6}",null,null,"900123"],[null,null,"808\\d{3}","\\d{6}",null,null,"808123"],[null,null,"700\\d{5}","\\d{8}",null,null,"70012345"],[null,null,"NA","NA"],"AL",355,"00","0",null,null,"0",null,null,null,[[null,"(4)(\\d{3})(\\d{4})","$1 $2 $3",["4[0-6]"],"0$1","",0],[null,"(6[6-9])(\\d{3})(\\d{4})","$1 $2 $3",["6"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2358][2-5]|4[7-9]"],"0$1","",0],[null,"(\\d{3})(\\d{3,5})","$1 $2",["[235][16-9]|8[016-9]|[79]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"12[789]","\\d{3}",null,null,"129"],[null,null,"NA","NA"]],"AM":[null,[null,null,"[1-9]\\d{7}","\\d{5,8}"],[null,null,"(?:1[01]\\d|2(?:2[2-46]|3[1-8]|4[2-69]|5[2-7]|6[1-9]|8[1-7])|3[12]2|47\\d)\\d{5}","\\d{5,8}",null,null,"10123456"],[null,null,"(?:55|77|9[1-9])\\d{6}","\\d{8}",null,null,"77123456"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"90[016]\\d{5}","\\d{8}",null,null,"90012345"],[null,null,"80[1-4]\\d{5}","\\d{8}",null,null,"80112345"],[null,null,"NA","NA"],[null,null,"60[2-6]\\d{5}","\\d{8}",null,null,"60271234"],"AM",374,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{6})","$1 $2",["1|47"],"(0$1)","",0],[null,"(\\d{2})(\\d{6})","$1 $2",["[5-7]|9[1-9]"],"0$1","",0],[null,"(\\d{3})(\\d{5})","$1 $2",["[23]"],"(0$1)","",0],[null,"(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8|90"],"0 $1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"10[123]","\\d{3}",null,null,"102"],[null,null,"NA","NA"]],"AO":[null,[null,null,"[29]\\d{8}","\\d{9}"],[null,null,"2\\d(?:[26-9]\\d|\\d[26-9])\\d{5}","\\d{9}",null,null,"222123456"],[null,null,"9[1-4]\\d{7}","\\d{9}",null,null,"923123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AO",244,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[235]","\\d{3}",null,null,"113"],[null,null,"NA","NA"]],"AR":[null,[null,null,"[1-368]\\d{9}|9\\d{10}","\\d{6,11}"],[null,null,"11\\d{8}|(?:2(?:2(?:[013]\\d|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[067]\\d)|4(?:7[3-8]|9\\d)|6(?:[01346]\\d|2[24-6]|5[15-8])|80\\d|9(?:[0124789]\\d|3[1-6]|5[234]|6[2-46]))|3(?:3(?:2[79]|6\\d|8[2578])|4(?:[78]\\d|0[0124-9]|[1-35]\\d|4[24-7]|6[02-9]|9[123678])|5(?:[138]\\d|2[1245]|4[1-9]|6[2-4]|7[1-6])|6[24]\\d|7(?:[0469]\\d|1[1568]|2[013-9]|3[145]|5[14-8]|7[2-57]|8[0-24-9])|8(?:[013578]\\d|2[15-7]|4[13-6]|6[1-357-9]|9[124]))|670\\d)\\d{6}","\\d{6,10}",null,null,"1123456789"],[null,null,"675\\d{7}|9(?:11[2-9]\\d{7}|(?:2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[12358]|5[138]|6[24]|7[069]|8[013578]))[2-9]\\d{6}|\\d{4}[2-9]\\d{5})","\\d{6,11}",null,null,"91123456789"],[null,null,"800\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"60[04579]\\d{7}","\\d{10}",null,null,"6001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AR",54,"00","0",null,null,"0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[124-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:1[1568]|2[15]|3[145]|4[13]|5[14-8]|[069]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?","9$1",null,null,[[null,"([68]\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1","",0],[null,"(9)(11)(\\d{4})(\\d{4})","$2 15-$3-$4",["911"],"0$1","",0],[null,"(9)(\\d{3})(\\d{3})(\\d{4})","$2 15-$3-$4",["9(?:2[234689]|3[3-8])","9(?:2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[12358]|5[138]|6[24]|7[069]|8[013578]))","9(?:2(?:2[013]|3[067]|49|6[01346]|80|9(?:[17-9]|4[13479]))|3(?:36|4[12358]|5(?:[18]|3[014-689])|6[24]|7[069]|8(?:[01]|3[013469]|5[0-39]|7[0-2459]|8[0-49])))"],"0$1","",0],[null,"(9)(\\d{4})(\\d{3})(\\d{3})","$2 15-$3-$4",["93[58]","9(?:3(?:53|8[78]))","9(?:3(?:537|8(?:73|88)))"],"0$1","",0],[null,"(9)(\\d{4})(\\d{2})(\\d{4})","$2 15-$3-$4",["9[23]"],"0$1","",0],[null,"(11)(\\d{4})(\\d{4})","$1 $2-$3",["1"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[12358]|5[138]|6[24]|7[069]|8[013578])","2(?:2[013]|3[067]|49|6[01346]|80|9(?:[17-9]|4[13479]))|3(?:36|4[12358]|5(?:[18]|3[0-689])|6[24]|7[069]|8(?:[01]|3[013469]|5[0-39]|7[0-2459]|8[0-49]))"],"0$1","",0],[null,"(\\d{4})(\\d{3})(\\d{3})","$1 $2-$3",["3(?:53|8[78])","3(?:537|8(?:73|88))"],"0$1","",0],[null,"(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["[23]"],"0$1","",0]],[[null,"([68]\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[68]","[68]"],"0$1","",0],[null,"(9)(11)(\\d{4})(\\d{4})","$1 $2 $3-$4",["911"]],[null,"(9)(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3-$4",["9(?:2[234689]|3[3-8])","9(?:2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[12358]|5[138]|6[24]|7[069]|8[013578]))","9(?:2(?:2[013]|3[067]|49|6[01346]|80|9(?:[17-9]|4[13479]))|3(?:36|4[12358]|5(?:[18]|3[014-689])|6[24]|7[069]|8(?:[01]|3[013469]|5[0-39]|7[0-2459]|8[0-49])))"]],[null,"(9)(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3-$4",["93[58]","9(?:3(?:53|8[78]))","9(?:3(?:537|8(?:73|88)))"]],[null,"(9)(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3-$4",["9[23]"]],[null,"(11)(\\d{4})(\\d{4})","$1 $2-$3",["1","1"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2-$3",["2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[12358]|5[138]|6[24]|7[069]|8[013578])","2(?:2[013]|3[067]|49|6[01346]|80|9(?:[17-9]|4[13479]))|3(?:36|4[12358]|5(?:[18]|3[0-689])|6[24]|7[069]|8(?:[01]|3[013469]|5[0-39]|7[0-2459]|8[0-49]))","2(?:2[013]|3[067]|49|6[01346]|80|9[147-9])|3(?:36|4[12358]|5[138]|6[24]|7[069]|8[013578])","2(?:2[013]|3[067]|49|6[01346]|80|9(?:[17-9]|4[13479]))|3(?:36|4[12358]|5(?:[18]|3[0-689])|6[24]|7[069]|8(?:[01]|3[013469]|5[0-39]|7[0-2459]|8[0-49]))"],"0$1","",0],[null,"(\\d{4})(\\d{3})(\\d{3})","$1 $2-$3",["3(?:53|8[78])","3(?:537|8(?:73|88))","3(?:53|8[78])","3(?:537|8(?:73|88))"],"0$1","",0],[null,"(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["[23]","[23]"],"0$1","",0]],[null,null,"NA","NA"],null,null,[null,null,"810\\d{7}","\\d{10}",null,null,"8101234567"],[null,null,"810\\d{7}","\\d{10}",null,null,"8101234567"],null,[null,null,"1(?:0[017]|28)","\\d{3}",null,null,"101"],[null,null,"NA","NA"]],"AS":[null,[null,null,"[5689]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"6846(?:22|33|44|55|77|88|9[19])\\d{4}","\\d{7}(?:\\d{3})?",null,null,"6846221234"],[null,null,"684(?:733|25[2468])\\d{4}","\\d{10}",null,null,"6847331234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"AS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"684",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"AT":[null,[null,null,"[1-9]\\d{3,12}","\\d{3,13}"],[null,null,"1\\d{3,12}|(?:2(?:1[467]|2[13-8]|5[2357]|6[1-46-8]|7[1-8]|8[124-7]|9[1458])|3(?:1[1-8]|3[23568]|4[5-7]|5[1378]|6[1-38]|8[3-68])|4(?:2[1-8]|35|63|7[1368]|8[2457])|5(?:12|2[1-8]|3[357]|4[147]|5[12578]|6[37])|6(?:13|2[1-47]|4[1-35-8]|5[468]|62)|7(?:2[1-8]|3[25]|4[13478]|5[68]|6[16-8]|7[1-6]|9[45]))\\d{3,10}","\\d{3,13}",null,null,"1234567890"],[null,null,"6(?:44|5[0-3579]|6[013-9]|[7-9]\\d)\\d{4,10}","\\d{7,13}",null,null,"644123456"],[null,null,"80[02]\\d{6,10}","\\d{9,13}",null,null,"800123456"],[null,null,"(?:711|9(?:0[01]|3[019]))\\d{6,10}","\\d{9,13}",null,null,"900123456"],[null,null,"8(?:10|2[018])\\d{6,10}","\\d{9,13}",null,null,"810123456"],[null,null,"NA","NA"],[null,null,"780\\d{6,10}","\\d{9,13}",null,null,"780123456"],"AT",43,"00","0",null,null,"0",null,null,null,[[null,"(1)(\\d{3,12})","$1 $2",["1"],"0$1","",0],[null,"(5\\d)(\\d{3,5})","$1 $2",["5[079]"],"0$1","",0],[null,"(5\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["5[079]"],"0$1","",0],[null,"(5\\d)(\\d{4})(\\d{4,7})","$1 $2 $3",["5[079]"],"0$1","",0],[null,"(\\d{3})(\\d{3,10})","$1 $2",["316|46|51|732|6(?:44|5[0-3579]|[6-9])|7(?:1|[28]0)|[89]"],"0$1","",0],[null,"(\\d{4})(\\d{3,9})","$1 $2",["2|3(?:1[1-578]|[3-8])|4[2378]|5[2-6]|6(?:[12]|4[1-35-9]|5[468])|7(?:2[1-8]|35|4[1-8]|[57-9])"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"5(?:(?:0[1-9]|17)\\d{2,10}|[79]\\d{3,11})|720\\d{6,10}","\\d{5,13}",null,null,"50123"],null,[null,null,"1(?:[12]2|33|44)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"AU":[null,[null,null,"[1-578]\\d{5,9}","\\d{6,10}"],[null,null,"[237]\\d{8}|8(?:[68]\\d{3}|7[0-69]\\d{2}|9(?:[02-9]\\d{2}|1(?:[0-57-9]\\d|6[0135-9])))\\d{4}","\\d{8,9}",null,null,"212345678"],[null,null,"14(?:5\\d|71)\\d{5}|4(?:[0-2]\\d|3[0-57-9]|4[47-9]|5[0-35-9]|6[6-9]|[79][07-9]|8[17-9])\\d{6}","\\d{9}",null,null,"412345678"],[null,null,"180(?:0\\d{3}|2)\\d{3}","\\d{7,10}",null,null,"1800123456"],[null,null,"19(?:0[0126]\\d{6}|[13-5]\\d{3}|[679]\\d{5})","\\d{6,10}",null,null,"1900123456"],[null,null,"13(?:00\\d{2})?\\d{4}","\\d{6,10}",null,null,"1300123456"],[null,null,"500\\d{6}","\\d{9}",null,null,"500123456"],[null,null,"550\\d{6}","\\d{9}",null,null,"550123456"],"AU",61,"(?:14(?:1[14]|34|4[17]|[56]6|7[47]|88))?001[14-689]","0",null,null,"0",null,"0011",null,[[null,"([2378])(\\d{4})(\\d{4})","$1 $2 $3",["[2378]"],"(0$1)","",0],[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[45]|14"],"0$1","",0],[null,"(16)(\\d{3})(\\d{2,4})","$1 $2 $3",["16"],"0$1","",0],[null,"(1[389]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[38]0|90)","1(?:[38]00|90)"],"$1","",0],[null,"(180)(2\\d{3})","$1 $2",["180","1802"],"$1","",0],[null,"(19\\d)(\\d{3})","$1 $2",["19[13]"],"$1","",0],[null,"(19\\d{2})(\\d{4})","$1 $2",["19[67]"],"$1","",0],[null,"(13)(\\d{2})(\\d{2})","$1 $2 $3",["13[1-9]"],"$1","",0]],null,[null,null,"16\\d{3,7}","\\d{5,9}",null,null,"1612345"],1,null,[null,null,"1(?:3(?:\\d{4}|00\\d{6})|80(?:0\\d{6}|2\\d{3}))","\\d{6,10}",null,null,"1300123456"],[null,null,"NA","NA"],null,[null,null,"000|112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"AW":[null,[null,null,"[25-9]\\d{6}","\\d{7}"],[null,null,"5(?:2\\d|8[1-9])\\d{4}","\\d{7}",null,null,"5212345"],[null,null,"(?:5(?:6\\d|9[2-478])|6(?:[039]0|22|4[01]|6[0-2])|7[34]\\d|9(?:6[45]|9[4-8]))\\d{4}","\\d{7}",null,null,"5601234"],[null,null,"800\\d{4}","\\d{7}",null,null,"8001234"],[null,null,"900\\d{4}","\\d{7}",null,null,"9001234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"28\\d{5}|501\\d{4}","\\d{7}",null,null,"5011234"],"AW",297,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"100|911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"AX":[null,[null,null,"[135]\\d{5,9}|[27]\\d{4,9}|4\\d{5,10}|6\\d{7,8}|8\\d{6,9}","\\d{5,12}"],[null,null,"18[1-8]\\d{3,9}","\\d{6,12}",null,null,"1812345678"],[null,null,"4\\d{5,10}|50\\d{4,8}","\\d{6,11}",null,null,"412345678"],[null,null,"800\\d{4,7}","\\d{7,10}",null,null,"8001234567"],[null,null,"[67]00\\d{5,6}","\\d{8,9}",null,null,"600123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AX",358,"00|99[049]","0",null,null,"0",null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"[13]00\\d{3,7}|2(?:0(?:0\\d{3,7}|2[023]\\d{1,6}|9[89]\\d{1,6}))|60(?:[12]\\d{5,6}|6\\d{7})|7(?:1\\d{7}|3\\d{8}|5[03-9]\\d{2,7})","\\d{5,10}",null,null,"100123"],[null,null,"[13]0\\d{4,8}|2(?:0(?:[016-8]\\d{3,7}|[2-59]\\d{2,7})|9\\d{4,8})|60(?:[12]\\d{5,6}|6\\d{7})|7(?:1\\d{7}|3\\d{8}|5[03-9]\\d{2,7})","\\d{5,10}",null,null,"10112345"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"AZ":[null,[null,null,"[1-9]\\d{8}","\\d{7,9}"],[null,null,"(?:1[28]\\d|2(?:02|1[24]|2[2-4]|33|[45]2|6[23])|365)\\d{6}","\\d{7,9}",null,null,"123123456"],[null,null,"(?:4[04]|5[015]|60|7[07])\\d{7}","\\d{9}",null,null,"401234567"],[null,null,"88\\d{7}","\\d{9}",null,null,"881234567"],[null,null,"900200\\d{3}","\\d{9}",null,null,"900200123"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AZ",994,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["(?:1[28]|2(?:[45]2|[0-36])|365)"],"(0$1)","",0],[null,"(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[4-8]"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:0[123]|12)","\\d{3}",null,null,"101"],[null,null,"NA","NA"]],"BA":[null,[null,null,"[3-9]\\d{7,8}","\\d{6,9}"],[null,null,"(?:[35]\\d|49)\\d{6}","\\d{6,8}",null,null,"30123456"],[null,null,"6(?:03|44|71|[1-356])\\d{6}","\\d{8,9}",null,null,"61123456"],[null,null,"8[08]\\d{6}","\\d{8}",null,null,"80123456"],[null,null,"9[0246]\\d{6}","\\d{8}",null,null,"90123456"],[null,null,"8[12]\\d{6}","\\d{8}",null,null,"82123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BA",387,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{3})","$1 $2-$3",["[3-5]"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["6[1-356]|[7-9]"],"0$1","",0],[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["6[047]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"70[23]\\d{5}","\\d{8}",null,null,"70223456"],null,[null,null,"12[234]","\\d{3}",null,null,"122"],[null,null,"NA","NA"]],"BB":[null,[null,null,"[2589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"246[2-9]\\d{6}","\\d{7}(?:\\d{3})?",null,null,"2462345678"],[null,null,"246(?:(?:2[346]|45|82)\\d|25[0-4])\\d{4}","\\d{10}",null,null,"2462501234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"BB",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"246",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"[235]11","\\d{3}",null,null,"211"],[null,null,"NA","NA"]],"BD":[null,[null,null,"[2-79]\\d{5,9}|1\\d{9}|8[0-7]\\d{4,8}","\\d{6,10}"],[null,null,"2(?:7(?:1[0-267]|2[0-289]|3[0-29]|[46][01]|5[1-3]|7[017]|91)|8(?:0[125]|[139][1-6]|2[0157-9]|6[1-35]|7[1-5]|8[1-8])|9(?:0[0-2]|1[1-4]|2[568]|3[3-6]|5[5-7]|6[0167]|7[15]|8[016-8]))\\d{4}|3(?:12?[5-7]\\d{2}|0(?:2(?:[025-79]\\d|[348]\\d{1,2})|3(?:[2-4]\\d|[56]\\d?))|2(?:1\\d{2}|2(?:[12]\\d|[35]\\d{1,2}|4\\d?))|3(?:1\\d{2}|2(?:[2356]\\d|4\\d{1,2}))|4(?:1\\d{2}|2(?:2\\d{1,2}|[47]|5\\d{2}))|5(?:1\\d{2}|29)|[67]1\\d{2}|8(?:1\\d{2}|2(?:2\\d{2}|3|4\\d))|)\\d{3}|4(?:0(?:2(?:[09]\\d|7)|33\\d{2})|1\\d{3}|2(?:1\\d{2}|2(?:[25]\\d?|[348]\\d|[67]\\d{1,2}))|3(?:1\\d{2}(?:\\d{2})?|2(?:[045]\\d|[236-9]\\d{1,2})|32\\d{2})|4(?:[18]\\d{2}|2(?:[2-46]\\d{2}|3)|5[25]\\d{2})|5(?:1\\d{2}|2(?:3\\d|5))|6(?:[18]\\d{2}|2(?:3(?:\\d{2})?|[46]\\d{1,2}|5\\d{2}|7\\d)|5(?:3\\d?|4\\d|[57]\\d{1,2}|6\\d{2}|8))|71\\d{2}|8(?:[18]\\d{2}|23\\d{2}|54\\d{2})|9(?:[18]\\d{2}|2[2-5]\\d{2}|53\\d{1,2}))\\d{3}|5(?:02[03489]\\d{2}|1\\d{2}|2(?:1\\d{2}|2(?:2(?:\\d{2})?|[457]\\d{2}))|3(?:1\\d{2}|2(?:[37](?:\\d{2})?|[569]\\d{2}))|4(?:1\\d{2}|2[46]\\d{2})|5(?:1\\d{2}|26\\d{1,2})|6(?:[18]\\d{2}|2|53\\d{2})|7(?:1|24)\\d{2}|8(?:1|26)\\d{2}|91\\d{2})\\d{3}|6(?:0(?:1\\d{2}|2(?:3\\d{2}|4\\d{1,2}))|2(?:2[2-5]\\d{2}|5(?:[3-5]\\d{2}|7)|8\\d{2})|3(?:1|2[3478])\\d{2}|4(?:1|2[34])\\d{2}|5(?:1|2[47])\\d{2}|6(?:[18]\\d{2}|6(?:2(?:2\\d|[34]\\d{2})|5(?:[24]\\d{2}|3\\d|5\\d{1,2})))|72[2-5]\\d{2}|8(?:1\\d{2}|2[2-5]\\d{2})|9(?:1\\d{2}|2[2-6]\\d{2}))\\d{3}|7(?:(?:02|[3-589]1|6[12]|72[24])\\d{2}|21\\d{3}|32)\\d{3}|8(?:(?:4[12]|[5-7]2|1\\d?)|(?:0|3[12]|[5-7]1|217)\\d)\\d{4}|9(?:[35]1|(?:[024]2|81)\\d|(?:1|[24]1)\\d{2})\\d{3}","\\d{6,9}",null,null,"27111234"],[null,null,"(?:1[13-9]\\d|(?:3[78]|44)[02-9]|6(?:44|6[02-9]))\\d{7}","\\d{10}",null,null,"1812345678"],[null,null,"80[03]\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"96(?:0[49]|1[0-4]|6[69])\\d{6}","\\d{10}",null,null,"9604123456"],"BD",880,"00[12]?","0",null,null,"0",null,"00",null,[[null,"(2)(\\d{7})","$1-$2",["2"],"0$1","",0],[null,"(\\d{2})(\\d{4,6})","$1-$2",["[3-79]1"],"0$1","",0],[null,"(\\d{4})(\\d{3,6})","$1-$2",["1|3(?:0|[2-58]2)|4(?:0|[25]2|3[23]|[4689][25])|5(?:[02-578]2|6[25])|6(?:[0347-9]2|[26][25])|7[02-9]2|8(?:[023][23]|[4-7]2)|9(?:[02][23]|[458]2|6[016])"],"0$1","",0],[null,"(\\d{3})(\\d{3,7})","$1-$2",["[3-79][2-9]|8"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"10[0-2]|999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"BE":[null,[null,null,"[1-9]\\d{7,8}","\\d{8,9}"],[null,null,"(?:1[0-69]|[23][2-8]|[49][23]|5\\d|6[013-57-9]|71)\\d{6}|8(?:0[1-9]|[1-79]\\d)\\d{5}","\\d{8}",null,null,"12345678"],[null,null,"4(?:[679]\\d|8[03-9])\\d{6}","\\d{9}",null,null,"470123456"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"(?:90|7[07])\\d{6}","\\d{8}",null,null,"90123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BE",32,"00","0",null,null,"0",null,null,null,[[null,"(4[6-9]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["4[6-9]"],"0$1","",0],[null,"([2-49])(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[23]|[49][23]"],"0$1","",0],[null,"([15-8]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[156]|7[0178]|8(?:0[1-9]|[1-79])"],"0$1","",0],[null,"([89]\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["(?:80|9)0"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"78\\d{6}","\\d{8}",null,null,"78123456"],null,[null,null,"1(?:0[01]|12)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"BF":[null,[null,null,"[24-7]\\d{7}","\\d{8}"],[null,null,"(?:20(?:49|5[23]|9[016-9])|40(?:4[56]|5[4-6]|7[0179])|50[34]\\d)\\d{4}","\\d{8}",null,null,"20491234"],[null,null,"6(?:[0-256]\\d|8[0-5]|3[0-3]|4[0-4])\\d{5}|7\\d{7}","\\d{8}",null,null,"70123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BF",226,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[78]","\\d{2}",null,null,"17"],[null,null,"NA","NA"]],"BG":[null,[null,null,"[23567]\\d{5,7}|[489]\\d{6,8}","\\d{5,9}"],[null,null,"2(?:[0-8]\\d{5,6}|9\\d{4,6})|(?:[36]\\d|5[1-9]|8[1-6]|9[1-7])\\d{5,6}|(?:4(?:[124-7]\\d|3[1-6])|7(?:0[1-9]|[1-9]\\d))\\d{4,5}","\\d{5,8}",null,null,"2123456"],[null,null,"(?:8[7-9]|98)\\d{7}|4(?:3[0789]|8\\d)\\d{5}","\\d{8,9}",null,null,"48123456"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"90\\d{6}","\\d{8}",null,null,"90123456"],[null,null,"NA","NA"],[null,null,"700\\d{5}","\\d{5,9}",null,null,"70012345"],[null,null,"NA","NA"],"BG",359,"00","0",null,null,"0",null,null,null,[[null,"(2)(\\d{5})","$1 $2",["29"],"0$1","",0],[null,"(2)(\\d{3})(\\d{3,4})","$1 $2 $3",["2"],"0$1","",0],[null,"(\\d{3})(\\d{4})","$1 $2",["43[124-7]|70[1-9]"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{2})","$1 $2 $3",["43[124-7]|70[1-9]"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[78]00"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["48|8[7-9]|9[08]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:12|50|6[06])","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"BH":[null,[null,null,"[136-9]\\d{7}","\\d{8}"],[null,null,"(?:1(?:3[13-6]|6[0156]|7\\d)\\d|6(?:1[16]\\d|6(?:0\\d|3[12]|44|88)|9(?:6[69]|9[6-9]))|7(?:7\\d{2}|178))\\d{4}","\\d{8}",null,null,"17001234"],[null,null,"(?:3(?:[1-4679]\\d|5[0135]|8[348])\\d|6(?:1[16]\\d|3(?:00|33|6[16])|500|6(?:[069]\\d|3[03-9]|44|88)|9(?:6[69]|9[6-9]))|77\\d{2})\\d{4}","\\d{8}",null,null,"36001234"],[null,null,"80\\d{6}","\\d{8}",null,null,"80123456"],[null,null,"(?:87|9[014578])\\d{6}","\\d{8}",null,null,"90123456"],[null,null,"84\\d{6}","\\d{8}",null,null,"84123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BH",973,"00",null,null,null,null,null,null,null,[[null,"(\\d{4})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"BI":[null,[null,null,"[27]\\d{7}","\\d{8}"],[null,null,"22(?:2[0-7]|[3-5]0)\\d{4}","\\d{8}",null,null,"22201234"],[null,null,"(?:29|7[14-9])\\d{6}","\\d{8}",null,null,"79561234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BI",257,"00",null,null,null,null,null,null,null,[[null,"([27]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[78]","\\d{3}",null,null,"117"],[null,null,"NA","NA"]],"BJ":[null,[null,null,"[2689]\\d{7}|7\\d{3}","\\d{4,8}"],[null,null,"2(?:02|1[037]|2[45]|3[68])\\d{5}","\\d{8}",null,null,"20211234"],[null,null,"(?:6[46-8]|9[03-9])\\d{6}","\\d{8}",null,null,"90011234"],[null,null,"7[3-5]\\d{2}","\\d{4}",null,null,"7312"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"857[58]\\d{4}","\\d{8}",null,null,"85751234"],"BJ",229,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"81\\d{6}","\\d{8}",null,null,"81123456"],null,[null,null,"11[78]","\\d{3}",null,null,"117"],[null,null,"NA","NA"]],"BL":[null,[null,null,"[56]\\d{8}","\\d{9}"],[null,null,"590(?:2[7-9]|5[12]|87)\\d{4}","\\d{9}",null,null,"590271234"],[null,null,"690(?:0[0-7]|[1-9]\\d)\\d{4}","\\d{9}",null,null,"690301234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BL",590,"00","0",null,null,"0",null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"18","\\d{2}",null,null,"18"],[null,null,"NA","NA"]],"BM":[null,[null,null,"[4589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"441(?:2(?:02|23|61|[3479]\\d)|[46]\\d{2}|5(?:4\\d|60|89)|824)\\d{4}","\\d{7}(?:\\d{3})?",null,null,"4412345678"],[null,null,"441(?:[37]\\d|5[0-39])\\d{5}","\\d{10}",null,null,"4413701234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"BM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"441",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"BN":[null,[null,null,"[2-578]\\d{6}","\\d{7}"],[null,null,"[2-5]\\d{6}","\\d{7}",null,null,"2345678"],[null,null,"[78]\\d{6}","\\d{7}",null,null,"7123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BN",673,"00",null,null,null,null,null,null,null,[[null,"([2-578]\\d{2})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"99[135]","\\d{3}",null,null,"991"],[null,null,"NA","NA"]],"BO":[null,[null,null,"[23467]\\d{7}","\\d{7,8}"],[null,null,"(?:2(?:2\\d{2}|5(?:11|[258]\\d|9[67])|6(?:12|2\\d|9[34])|8(?:2[34]|39|62))|3(?:3\\d{2}|4(?:6\\d|8[24])|8(?:25|42|5[257]|86|9[25])|9(?:2\\d|3[234]|4[248]|5[24]|6[2-6]|7\\d))|4(?:4\\d{2}|6(?:11|[24689]\\d|72)))\\d{4}","\\d{7,8}",null,null,"22123456"],[null,null,"[67]\\d{7}","\\d{8}",null,null,"71234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BO",591,"00(1\\d)?","0",null,null,"0(1\\d)?",null,null,null,[[null,"([234])(\\d{7})","$1 $2",["[234]"],"","0$CC $1",0],[null,"([67]\\d{7})","$1",["[67]"],"","0$CC $1",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[089]","\\d{3}",null,null,"110"],[null,null,"NA","NA"]],"BQ":[null,[null,null,"[347]\\d{6}","\\d{7}"],[null,null,"(?:318[023]|416[0239]|7(?:1[578]|50)\\d)\\d{3}","\\d{7}",null,null,"7151234"],[null,null,"(?:318[1456]|416[15-8]|7(?:0[01]|[89]\\d)\\d)\\d{3}|","\\d{7}",null,null,"3181234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BQ",599,"00",null,null,null,null,null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|911","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"BR":[null,[null,null,"[1-46-9]\\d{7,10}|5\\d{8,9}","\\d{8,11}"],[null,null,"1[1-9][2-5]\\d{7}|(?:[4689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-5]\\d{7}","\\d{8,11}",null,null,"1123456789"],[null,null,"1(?:1(?:5[347]|[6-9]\\d|)|[2-9][6-9]\\d)\\d{6}|(?:2[12478]|3[1-578]|[4689][1-9]|5[13-5]|7[13-579])[6-9]\\d{7}|(?:1(?:19\\d|[2-9]9[6-9])|2[12478]9[6-9])\\d{7}","\\d{10,11}",null,null,"1161234567"],[null,null,"800\\d{6,7}","\\d{8,11}",null,null,"800123456"],[null,null,"[359]00\\d{6,7}","\\d{8,11}",null,null,"300123456"],[null,null,"[34]00\\d{5}","\\d{8}",null,null,"40041234"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BR",55,"00(?:1[45]|2[135]|[34]1|43)","0",null,null,"0(?:(1[245]|2[135]|[34]1)(\\d{10,11}))?","$2",null,null,[[null,"(\\d{4})(\\d{4})","$1-$2",["[2-9](?:[1-9]|0[1-9])"],"$1","",0],[null,"(\\d{5})(\\d{4})","$1-$2",["9(?:[1-9]|0[1-9])"],"$1","",0],[null,"(\\d{3,5})","$1",["1[125689]"],"$1","",0],[null,"(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["(?:1[1-9]|2[12478])9"],"($1)","0 $CC ($1)",0],[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["[1-9][1-9]"],"($1)","0 $CC ($1)",0],[null,"([34]00\\d)(\\d{4})","$1-$2",["[34]00"],"","",0],[null,"([3589]00)(\\d{2,3})(\\d{4})","$1 $2 $3",["[3589]00"],"0$1","",0]],[[null,"(\\d{2})(\\d{5})(\\d{4})","$1 $2-$3",["(?:1[1-9]|2[12478])9","(?:1[1-9]|2[12478])9"],"($1)","0 $CC ($1)",0],[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["[1-9][1-9]","[1-9][1-9]"],"($1)","0 $CC ($1)",0],[null,"([34]00\\d)(\\d{4})","$1-$2",["[34]00","[34]00"],"","",0],[null,"([3589]00)(\\d{2,3})(\\d{4})","$1 $2 $3",["[3589]00","[3589]00"],"0$1","",0]],[null,null,"NA","NA"],null,null,[null,null,"[34]00\\d{5}","\\d{8}",null,null,"40041234"],[null,null,"NA","NA"],null,[null,null,"1(?:12|28|9[023])|911","\\d{3}",null,null,"190"],[null,null,"NA","NA"]],"BS":[null,[null,null,"[2589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"242(?:3(?:02|[236][1-9]|4[0-24-9]|5[0-68]|7[3467]|8[0-4]|9[2-467])|461|502|6(?:12|7[67]|8[78]|9[89])|702)\\d{4}","\\d{7}(?:\\d{3})?",null,null,"2423456789"],[null,null,"242(?:3(?:5[79]|[79]5)|4(?:[2-4][1-9]|5[1-8]|6[2-8]|7\\d|81)|5(?:2[45]|3[35]|44|5[1-9]|65|77)|6[34]6|727)\\d{4}","\\d{10}",null,null,"2423591234"],[null,null,"242300\\d{4}|8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"BS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"242",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"91[19]","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"BT":[null,[null,null,"[1-8]\\d{6,7}","\\d{6,8}"],[null,null,"(?:2[3-6]|[34][5-7]|5[236]|6[2-46]|7[246]|8[2-4])\\d{5}","\\d{6,7}",null,null,"2345678"],[null,null,"[17]7\\d{6}","\\d{8}",null,null,"17123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BT",975,"00",null,null,null,null,null,null,null,[[null,"([17]7)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1|77"],"","",0],[null,"([2-8])(\\d{3})(\\d{3})","$1 $2 $3",["[2-68]|7[246]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[023]","\\d{3}",null,null,"113"],[null,null,"NA","NA"]],"BW":[null,[null,null,"[2-79]\\d{6,7}","\\d{7,8}"],[null,null,"(?:2(?:4[0-48]|6[0-24]|9[0578])|3(?:1[0235-9]|55|6\\d|7[01]|9[0-57])|4(?:6[03]|7[1267]|9[0-5])|5(?:3[0389]|4[0489]|7[1-47]|88|9[0-49])|6(?:2[1-35]|5[149]|8[067]))\\d{4}","\\d{7}",null,null,"2401234"],[null,null,"7(?:[1-35]\\d{6}|[46][0-7]\\d{5}|7[01]\\d{5})","\\d{8}",null,null,"71123456"],[null,null,"NA","NA"],[null,null,"90\\d{5}","\\d{7}",null,null,"9012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"79[12][01]\\d{4}","\\d{8}",null,null,"79101234"],"BW",267,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",["[2-6]"],"","",0],[null,"(7\\d)(\\d{3})(\\d{3})","$1 $2 $3",["7"],"","",0],[null,"(90)(\\d{5})","$1 $2",["9"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"99[789]","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"BY":[null,[null,null,"[1-4]\\d{8}|[89]\\d{9,10}","\\d{7,11}"],[null,null,"(?:1(?:5(?:1[1-5]|2\\d|6[2-4]|9[1-7])|6(?:[235]\\d|4[1-7])|7\\d{2})|2(?:1(?:[246]\\d|3[0-35-9]|5[1-9])|2(?:[235]\\d|4[0-8])|3(?:2\\d|3[02-79]|4[024-7]|5[0-7])))\\d{5}","\\d{7,9}",null,null,"152450911"],[null,null,"(?:2(?:5[5679]|9[1-9])|33\\d|44\\d)\\d{6}","\\d{9}",null,null,"294911911"],[null,null,"8(?:0[13]|20\\d)\\d{7}","\\d{10,11}",null,null,"8011234567"],[null,null,"(?:810|902)\\d{7}","\\d{10}",null,null,"9021234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BY",375,"810","8",null,null,"8?0?",null,"8~10",null,[[null,"([1-4]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[1-4]"],"8 0$1","",0],[null,"([89]\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8[01]|9"],"8 $1","",0],[null,"(8\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["82"],"8 $1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"8(?:[01]|20)\\d{8}|902\\d{7}","\\d{10,11}",null,null,"82012345678"],[null,null,"NA","NA"],null,[null,null,"1(?:0[123]|12)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"BZ":[null,[null,null,"[2-8]\\d{6}|0\\d{10}","\\d{7}(?:\\d{4})?"],[null,null,"[234578][02]\\d{5}","\\d{7}",null,null,"2221234"],[null,null,"6[0-367]\\d{5}","\\d{7}",null,null,"6221234"],[null,null,"0800\\d{7}","\\d{11}",null,null,"08001234123"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BZ",501,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1-$2",["[2-8]"],"","",0],[null,"(0)(800)(\\d{4})(\\d{3})","$1-$2-$3-$4",["0"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"9(?:0|11)","\\d{2,3}",null,null,"911"],[null,null,"NA","NA"]],"CA":[null,[null,null,"[2-9]\\d{9}|3\\d{6}","\\d{7}(?:\\d{3})?"],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|5[06])|5(?:0[06]|1[49]|79|8[17])|6(?:0[04]|13|39|47)|7(?:0[059]|80|78)|8(?:[06]7|19|73)|90[25])[2-9]\\d{6}","\\d{7}(?:\\d{3})?",null,null,"2042345678"],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|5[06])|5(?:0[06]|1[49]|79|8[17])|6(?:0[04]|13|39|47)|7(?:0[059]|80|78)|8(?:[06]7|19|73)|90[25])[2-9]\\d{6}","\\d{7}(?:\\d{3})?",null,null,"2042345678"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{7}(?:\\d{3})?",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"CA",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"CC":[null,[null,null,"[1458]\\d{5,9}","\\d{6,10}"],[null,null,"89162\\d{4}","\\d{8,9}",null,null,"891621234"],[null,null,"4(?:[0-2]\\d|3[0-57-9]|4[47-9]|5[0-37-9]|6[6-9]|7[07-9]|8[7-9])\\d{6}","\\d{9}",null,null,"412345678"],[null,null,"1(?:80(?:0\\d{2})?|3(?:00\\d{2})?)\\d{4}","\\d{6,10}",null,null,"1800123456"],[null,null,"190[0126]\\d{6}","\\d{10}",null,null,"1900123456"],[null,null,"NA","NA"],[null,null,"500\\d{6}","\\d{9}",null,null,"500123456"],[null,null,"550\\d{6}","\\d{9}",null,null,"550123456"],"CC",61,"(?:14(?:1[14]|34|4[17]|[56]6|7[47]|88))?001[14-689]","0",null,null,"0",null,"0011",null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"000|112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"CD":[null,[null,null,"[2-6]\\d{6}|[18]\\d{6,8}|9\\d{8}","\\d{7,9}"],[null,null,"1(?:2\\d{7}|\\d{6})|[2-6]\\d{6}","\\d{7,9}",null,null,"1234567"],[null,null,"8(?:[0-2459]\\d{2}|8)\\d{5}|9[7-9]\\d{7}","\\d{7,9}",null,null,"991234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CD",243,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["12"],"0$1","",0],[null,"([89]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8[0-2459]|9"],"0$1","",0],[null,"(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["88"],"0$1","",0],[null,"(\\d{2})(\\d{5})","$1 $2",["[1-6]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"CF":[null,[null,null,"[278]\\d{7}","\\d{8}"],[null,null,"2[12]\\d{6}","\\d{8}",null,null,"21612345"],[null,null,"7[0257]\\d{6}","\\d{8}",null,null,"70012345"],[null,null,"NA","NA"],[null,null,"8776\\d{4}","\\d{8}",null,null,"87761234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CF",236,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"CG":[null,[null,null,"[028]\\d{8}","\\d{9}"],[null,null,"222[1-589]\\d{5}","\\d{9}",null,null,"222123456"],[null,null,"0[14-6]\\d{7}","\\d{9}",null,null,"061234567"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CG",242,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[02]"],"","",0],[null,"(\\d)(\\d{4})(\\d{4})","$1 $2 $3",["8"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"NA","NA"],[null,null,"NA","NA"]],"CH":[null,[null,null,"[2-9]\\d{8}|860\\d{9}","\\d{9}(?:\\d{3})?"],[null,null,"(?:2[12467]|3[1-4]|4[134]|5[12568]|6[12]|[7-9]1)\\d{7}","\\d{9}",null,null,"212345678"],[null,null,"7[4-9]\\d{7}","\\d{9}",null,null,"741234567"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"90[016]\\d{6}","\\d{9}",null,null,"900123456"],[null,null,"84[0248]\\d{6}","\\d{9}",null,null,"840123456"],[null,null,"878\\d{6}","\\d{9}",null,null,"878123456"],[null,null,"NA","NA"],"CH",41,"00","0",null,null,"0",null,null,null,[[null,"([2-9]\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-7]|[89]1"],"0$1","",0],[null,"([89]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8[047]|90"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["860"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:1[278]|44)","\\d{3}",null,null,"112"],[null,null,"860\\d{9}","\\d{12}",null,null,"860123456789"]],"CI":[null,[null,null,"[02-6]\\d{7}","\\d{8}"],[null,null,"(?:2(?:0[023]|1[02357]|[23][045]|4[03-5])|3(?:0[06]|1[069]|[2-4][07]|5[09]|6[08]))\\d{5}","\\d{8}",null,null,"21234567"],[null,null,"(?:0[1-9]|4[0-24-9]|5[05-9]|6[05679])\\d{6}","\\d{8}",null,null,"01234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CI",225,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"1(?:1[01]|[78]0)","\\d{3}",null,null,"110"],[null,null,"NA","NA"]],"CK":[null,[null,null,"[2-57]\\d{4}","\\d{5}"],[null,null,"(?:2\\d|3[13-7]|4[1-5])\\d{3}","\\d{5}",null,null,"21234"],[null,null,"(?:5[0-68]|7\\d)\\d{3}","\\d{5}",null,null,"71234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CK",682,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{3})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"99[689]","\\d{3}",null,null,"998"],[null,null,"NA","NA"]],"CL":[null,[null,null,"(?:[2-9]|600|123)\\d{7,8}","\\d{6,11}"],[null,null,"(?:[23]2|41|58)\\d{7}|(?:3[3-5]|4[235]|5[1-357]|6[13-57]|7[1-35])\\d{6,7}","\\d{6,9}",null,null,"221234567"],[null,null,"9[5-9]\\d{7}","\\d{8,9}",null,null,"961234567"],[null,null,"800\\d{6}|1230\\d{7}","\\d{9,11}",null,null,"800123456"],[null,null,"NA","NA"],[null,null,"600\\d{7,8}","\\d{10,11}",null,null,"6001234567"],[null,null,"NA","NA"],[null,null,"44\\d{7}","\\d{9}",null,null,"441234567"],"CL",56,"(?:0|1(?:1[0-69]|2[0-57]|5[13-58]|69|7[0167]|8[018]))0","0",null,null,"0|(1(?:1[0-69]|2[0-57]|5[13-58]|69|7[0167]|8[018]))",null,null,null,[[null,"(2)(\\d{3,4})(\\d{4})","$1 $2 $3",["2"],"($1)","$CC ($1)",0],[null,"(\\d{2})(\\d{2,3})(\\d{4})","$1 $2 $3",["[357]|4[1-35]|6[13-57]"],"($1)","$CC ($1)",0],[null,"(9)([5-9]\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1","",0],[null,"(44)(\\d{3})(\\d{4})","$1 $2 $3",["44"],"0$1","",0],[null,"([68]00)(\\d{3})(\\d{3,4})","$1 $2 $3",["60|8"],"$1","",0],[null,"(600)(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3 $4",["60"],"$1","",0],[null,"(1230)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"600\\d{7,8}","\\d{10,11}",null,null,"6001234567"],[null,null,"NA","NA"],null,[null,null,"13[123]","\\d{3}",null,null,"133"],[null,null,"NA","NA"]],"CM":[null,[null,null,"[2357-9]\\d{7}","\\d{8}"],[null,null,"(?:22|33)\\d{6}","\\d{8}",null,null,"22123456"],[null,null,"[579]\\d{7}","\\d{8}",null,null,"71234567"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"88\\d{6}","\\d{8}",null,null,"88012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CM",237,"00",null,null,null,null,null,null,null,[[null,"([2357-9]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[23579]|88"],"","",0],[null,"(800)(\\d{2})(\\d{3})","$1 $2 $3",["80"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1?1[37]","\\d{2,3}",null,null,"113"],[null,null,"NA","NA"]],"CN":[null,[null,null,"[1-7]\\d{6,11}|8[0-357-9]\\d{6,9}|9(?:5\\d{3,4}|\\d{9})","\\d{4,12}"],[null,null,"21(?:95\\d{3,4}|\\d{8,10})|(?:10|2[02-57-9]|3(?:11|7[179])|4(?:[15]1|3[12])|5(?:1\\d|2[37]|3[12]|51|7[13-79]|9[15])|7(?:31|5[457]|6[09]|91)|8(?:71|98))(?:95\\d{3,4}|\\d{8})|(?:3(?:1[02-9]|35|49|5\\d|7[02-68]|9[1-68])|4(?:1[02-9]|2[179]|3[3-9]|5[2-9]|6[4789]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[17]\\d|2[248]|3[04-9]|4[3-6]|5[0-3689]|6[2368]|9[02-9])|8(?:1[236-8]|2[5-7]|3\\d|5[1-9]|7[02-9]|8[3678]|9[1-7])|9(?:0[1-3689]|1[1-79]|[379]\\d|4[13]|5[1-5]))(?:95\\d{3,4}|\\d{7})|80(?:29|6[03578]|7[018]|81)\\d{4}","\\d{4,12}",null,null,"1012345678"],[null,null,"1(?:3\\d|4[57]|[58][0-35-9])\\d{8}","\\d{11}",null,null,"13123456789"],[null,null,"(?:10)?800\\d{7}","\\d{10,12}",null,null,"8001234567"],[null,null,"16[08]\\d{5}","\\d{8}",null,null,"16812345"],[null,null,"400\\d{7}|95\\d{3,4}","\\d{5,10}",null,null,"4001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CN",86,"(1[1279]\\d{3})?00","0",null,null,"(1[1279]\\d{3})|0",null,"00",null,[[null,"(80\\d{2})(\\d{4})","$1 $2",["80[2678]"],"0$1","$CC $1",1],[null,"([48]00)(\\d{3})(\\d{4})","$1 $2 $3",["[48]00"],"","",0],[null,"(\\d{5})","$1",["95"],"","",0],[null,"(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2\\d)9","(?:10|2\\d)95"],"0$1","$CC $1",0],[null,"(\\d{3})(\\d{5,6})","$1 $2",["[3-9]","[3-9]\\d{2}9","[3-9]\\d{2}95"],"0$1","$CC $1",0],[null,"(\\d{3,4})(\\d{4})","$1 $2",["[2-9]"],"","",0],[null,"(21)(\\d{4})(\\d{4,6})","$1 $2 $3",["21"],"0$1","$CC $1",1],[null,"([12]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["10[1-9]|2[02-9]","10[1-9]|2[02-9]","10(?:[1-79]|8(?:[1-9]|0[1-9]))|2[02-9]"],"0$1","$CC $1",1],[null,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["3(?:11|7[179])|4(?:[15]1|3[12])|5(?:1|2[37]|3[12]|51|7[13-79]|9[15])|7(?:31|5[457]|6[09]|91)|8(?:71|98)"],"0$1","$CC $1",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:1[02-9]|35|49|5|7[02-68]|9[1-68])|4(?:1[02-9]|2[179]|[35][2-9]|6[4789]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[04-9]|4[3-6]|6[2368])|8(?:1[236-8]|2[5-7]|3|5[1-9]|7[02-9]|8[3678]|9[1-7])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])"],"0$1","$CC $1",1],[null,"(1[3-58]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["1[3-58]"],"","$CC $1",0],[null,"(10800)(\\d{3})(\\d{4})","$1 $2 $3",["108","1080","10800"],"","",0]],[[null,"(80\\d{2})(\\d{4})","$1 $2",["80[2678]","80[2678]"],"0$1","$CC $1",1],[null,"([48]00)(\\d{3})(\\d{4})","$1 $2 $3",["[48]00","[48]00"],"","",0],[null,"(\\d{5})","$1",["95","95"],"","",0],[null,"(\\d{2})(\\d{5,6})","$1 $2",["(?:10|2\\d)9","(?:10|2\\d)95","(?:10|2\\d)9","(?:10|2\\d)95"],"0$1","$CC $1",0],[null,"(\\d{3})(\\d{5,6})","$1 $2",["[3-9]","[3-9]\\d{2}9","[3-9]\\d{2}95","[3-9]","[3-9]\\d{2}9","[3-9]\\d{2}95"],"0$1","$CC $1",0],[null,"(21)(\\d{4})(\\d{4,6})","$1 $2 $3",["21","21"],"0$1","$CC $1",1],[null,"([12]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["10[1-9]|2[02-9]","10[1-9]|2[02-9]","10(?:[1-79]|8(?:[1-9]|0[1-9]))|2[02-9]","10[1-9]|2[02-9]","10[1-9]|2[02-9]","10(?:[1-79]|8(?:[1-9]|0[1-9]))|2[02-9]"],"0$1","$CC $1",1],[null,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["3(?:11|7[179])|4(?:[15]1|3[12])|5(?:1|2[37]|3[12]|51|7[13-79]|9[15])|7(?:31|5[457]|6[09]|91)|8(?:71|98)","3(?:11|7[179])|4(?:[15]1|3[12])|5(?:1|2[37]|3[12]|51|7[13-79]|9[15])|7(?:31|5[457]|6[09]|91)|8(?:71|98)"],"0$1","$CC $1",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["3(?:1[02-9]|35|49|5|7[02-68]|9[1-68])|4(?:1[02-9]|2[179]|[35][2-9]|6[4789]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[04-9]|4[3-6]|6[2368])|8(?:1[236-8]|2[5-7]|3|5[1-9]|7[02-9]|8[3678]|9[1-7])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])","3(?:1[02-9]|35|49|5|7[02-68]|9[1-68])|4(?:1[02-9]|2[179]|[35][2-9]|6[4789]|7\\d|8[23])|5(?:3[03-9]|4[36]|5[02-9]|6[1-46]|7[028]|80|9[2-46-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[04-9]|4[3-6]|6[2368])|8(?:1[236-8]|2[5-7]|3|5[1-9]|7[02-9]|8[3678]|9[1-7])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])"],"0$1","$CC $1",1],[null,"(1[3-58]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["1[3-58]","1[3-58]"],"","$CC $1",0],[null,"(10800)(\\d{3})(\\d{4})","$1 $2 $3",["108","1080","10800","108","1080","10800"],"","",0]],[null,null,"NA","NA"],null,null,[null,null,"(?:4|(?:10)?8)00\\d{7}|95\\d{3}","\\d{5,12}",null,null,"4001234567"],[null,null,"NA","NA"],null,[null,null,"1(?:1[09]|20)","\\d{3}",null,null,"119"],[null,null,"NA","NA"]],"CO":[null,[null,null,"(?:[13]\\d{0,3}|[24-8])\\d{7}","\\d{7,11}"],[null,null,"[124-8][2-9]\\d{6}","\\d{8}",null,null,"12345678"],[null,null,"3(?:0[0-24]|1\\d|2[01])\\d{7}","\\d{10}",null,null,"3211234567"],[null,null,"1800\\d{7}","\\d{11}",null,null,"18001234567"],[null,null,"19(?:0[01]|4[78])\\d{7}","\\d{11}",null,null,"19001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CO",57,"00[579]|#555|#999","0",null,null,"0([3579]|4(?:44|56))?",null,null,null,[[null,"(\\d)(\\d{7})","$1 $2",["1(?:8[2-9]|9[0-3]|[2-7])|[24-8]","1(?:8[2-9]|9(?:09|[1-3])|[2-7])|[24-8]"],"($1)","0$CC $1",0],[null,"(\\d{3})(\\d{7})","$1 $2",["3"],"","0$CC $1",0],[null,"(1)(\\d{3})(\\d{7})","$1-$2-$3",["1(?:80|9[04])","1(?:800|9(?:0[01]|4[78]))"],"0$1","",0]],[[null,"(\\d)(\\d{7})","$1 $2",["1(?:8[2-9]|9[0-3]|[2-7])|[24-8]","1(?:8[2-9]|9(?:09|[1-3])|[2-7])|[24-8]","1(?:8[2-9]|9[0-3]|[2-7])|[24-8]","1(?:8[2-9]|9(?:09|[1-3])|[2-7])|[24-8]"],"($1)","0$CC $1",0],[null,"(\\d{3})(\\d{7})","$1 $2",["3","3"],"","0$CC $1",0],[null,"(1)(\\d{3})(\\d{7})","$1 $2 $3",["1(?:80|9[04])","1(?:800|9(?:0[01]|4[78]))"]]],[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:1[29]|23|32|56)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"CR":[null,[null,null,"[24-9]\\d{7,9}","\\d{8,10}"],[null,null,"2[24-7]\\d{6}","\\d{8}",null,null,"22123456"],[null,null,"5(?:0[0-4]|7[01])\\d{5}|[67][0-2]\\d{6}|8[3-9]\\d{6}","\\d{8}",null,null,"83123456"],[null,null,"800\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"90[059]\\d{7}","\\d{10}",null,null,"9001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"210[0-6]\\d{4}|4(?:0(?:[04]0\\d{4}|10[0-3]\\d{3}|2(?:00\\d|900)\\d{2}|3[01]\\d{4}|5\\d{5}|70[01]\\d{3}|8[0-2]\\d{4})|1[01]\\d{5}|20[0-3]\\d{4}|400\\d{4}|70[0-2]\\d{4})|5100\\d{4}","\\d{8}",null,null,"40001234"],"CR",506,"00",null,null,null,"(19(?:0[0-2468]|19|20|66|77))",null,null,null,[[null,"(\\d{4})(\\d{4})","$1 $2",["[24-7]|8[3-9]"],"","$CC $1",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[89]0"],"","$CC $1",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"CU":[null,[null,null,"[2-57]\\d{5,7}","\\d{4,8}"],[null,null,"2[1-4]\\d{5,6}|3(?:1\\d{6}|[23]\\d{4,6})|4(?:[125]\\d{5,6}|[36]\\d{6}|[78]\\d{4,6})|7\\d{6,7}","\\d{4,8}",null,null,"71234567"],[null,null,"5\\d{7}","\\d{8}",null,null,"51234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CU",53,"119","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{6,7})","$1 $2",["7"],"(0$1)","",0],[null,"(\\d{2})(\\d{4,6})","$1 $2",["[2-4]"],"(0$1)","",0],[null,"(\\d)(\\d{7})","$1 $2",["5"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"10[456]","\\d{3}",null,null,"106"],[null,null,"NA","NA"]],"CV":[null,[null,null,"[259]\\d{6}","\\d{7}"],[null,null,"2(?:2[1-7]|3[0-8]|4[12]|5[1256]|6\\d|7[1-3]|8[1-5])\\d{4}","\\d{7}",null,null,"2211234"],[null,null,"(?:9\\d|59)\\d{5}","\\d{7}",null,null,"9911234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CV",238,"0",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"13[012]","\\d{3}",null,null,"132"],[null,null,"NA","NA"]],"CW":[null,[null,null,"[169]\\d{6,7}","\\d{7,8}"],[null,null,"9(?:[48]\\d{2}|50\\d|7(?:2[0-2]|[34]\\d|6[35-7]|77))\\d{4}","\\d{7,8}",null,null,"94151234"],[null,null,"9(?:5(?:[1246]\\d|3[01])|6(?:[1679]\\d|3[01]))\\d{4}","\\d{7,8}",null,null,"95181234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"(?:10|69)\\d{5}","\\d{7}",null,null,"1011234"],[null,null,"NA","NA"],[null,null,"NA","NA"],"CW",599,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",["[13-7]"],"","",0],[null,"(9)(\\d{3})(\\d{4})","$1 $2 $3",["9"],"","",0]],null,[null,null,"955\\d{5}","\\d{7,8}",null,null,"95581234"],1,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|911","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"CY":[null,[null,null,"[257-9]\\d{7}","\\d{8}"],[null,null,"2[2-6]\\d{6}","\\d{8}",null,null,"22345678"],[null,null,"9[5-79]\\d{6}","\\d{8}",null,null,"96123456"],[null,null,"800\\d{5}","\\d{8}",null,null,"80001234"],[null,null,"90[09]\\d{5}","\\d{8}",null,null,"90012345"],[null,null,"80[1-9]\\d{5}","\\d{8}",null,null,"80112345"],[null,null,"700\\d{5}","\\d{8}",null,null,"70012345"],[null,null,"NA","NA"],"CY",357,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{6})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"(?:50|77)\\d{6}","\\d{8}",null,null,"77123456"],null,[null,null,"1(?:12|99)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"CX":[null,[null,null,"[1458]\\d{5,9}","\\d{6,10}"],[null,null,"89164\\d{4}","\\d{8,9}",null,null,"891641234"],[null,null,"4(?:[0-2]\\d|3[0-57-9]|4[47-9]|5[0-37-9]|6[6-9]|7[07-9]|8[7-9])\\d{6}","\\d{9}",null,null,"412345678"],[null,null,"1(?:80(?:0\\d{2})?|3(?:00\\d{2})?)\\d{4}","\\d{6,10}",null,null,"1800123456"],[null,null,"190[0126]\\d{6}","\\d{10}",null,null,"1900123456"],[null,null,"NA","NA"],[null,null,"500\\d{6}","\\d{9}",null,null,"500123456"],[null,null,"550\\d{6}","\\d{9}",null,null,"550123456"],"CX",61,"(?:14(?:1[14]|34|4[17]|[56]6|7[47]|88))?001[14-689]","0",null,null,"0",null,"0011",null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"000|112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"CZ":[null,[null,null,"[2-8]\\d{8}|9\\d{8,11}","\\d{9,12}"],[null,null,"2\\d{8}|(?:3[1257-9]|4[16-9]|5[13-9])\\d{7}","\\d{9,12}",null,null,"212345678"],[null,null,"(?:60[1-8]|7(?:0[2-5]|[2379]\\d))\\d{6}","\\d{9,12}",null,null,"601123456"],[null,null,"800\\d{6}","\\d{9,12}",null,null,"800123456"],[null,null,"9(?:0[05689]|76)\\d{6}","\\d{9,12}",null,null,"900123456"],[null,null,"8[134]\\d{7}","\\d{9,12}",null,null,"811234567"],[null,null,"70[01]\\d{6}","\\d{9,12}",null,null,"700123456"],[null,null,"9[17]0\\d{6}","\\d{9,12}",null,null,"910123456"],"CZ",420,"00",null,null,null,null,null,null,null,[[null,"([2-9]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-8]|9[015-7]"],"","",0],[null,"(96\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["96"],"","",0],[null,"(9\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9[36]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"9(?:5\\d|7[234])\\d{6}","\\d{9,12}",null,null,"972123456"],null,[null,null,"1(?:12|5[058])","\\d{3}",null,null,"112"],[null,null,"9(?:3\\d{9}|6\\d{7,10})","\\d{9,12}",null,null,"93123456789"]],"DE":[null,[null,null,"[1-35-9]\\d{3,14}|4(?:[0-8]\\d{4,12}|9(?:[0-37]\\d|4(?:[1-35-8]|4\\d?)|5\\d{1,2}|6[1-8]\\d?)\\d{2,7})","\\d{2,15}"],[null,null,"[246]\\d{5,13}|3(?:[03-9]\\d{4,13}|2\\d{9})|5(?:0[2-8]|[1256]\\d|[38][0-8]|4\\d{0,2}|[79][0-7])\\d{3,11}|7(?:0[2-8]|[1-9]\\d)\\d{3,10}|8(?:0[2-9]|[1-9]\\d)\\d{3,10}|9(?:0[6-9]\\d{3,10}|1\\d{4,12}|[2-9]\\d{4,11})","\\d{2,15}",null,null,"30123456"],[null,null,"1(?:5[0-2579]\\d{8}|6[023]\\d{7,8}|7(?:[0-57-9]\\d?|6\\d)\\d{7})","\\d{10,11}",null,null,"15123456789"],[null,null,"800\\d{7,12}","\\d{10,15}",null,null,"8001234567890"],[null,null,"900(?:[135]\\d{6}|9\\d{7})","\\d{10,11}",null,null,"9001234567"],[null,null,"180\\d{5,11}","\\d{8,14}",null,null,"18012345"],[null,null,"700\\d{8}","\\d{11}",null,null,"70012345678"],[null,null,"NA","NA"],"DE",49,"00","0",null,null,"0",null,null,null,[[null,"(1\\d{2})(\\d{7,8})","$1 $2",["1[67]"],"0$1","",0],[null,"(1\\d{3})(\\d{7})","$1 $2",["15"],"0$1","",0],[null,"(\\d{2})(\\d{4,11})","$1 $2",["3[02]|40|[68]9"],"0$1","",0],[null,"(\\d{3})(\\d{3,11})","$1 $2",["2(?:\\d1|0[2389]|1[24]|28|34)|3(?:[3-9][15]|40)|[4-8][1-9]1|9(?:06|[1-9]1)"],"0$1","",0],[null,"(\\d{4})(\\d{2,11})","$1 $2",["[24-6]|[7-9](?:\\d[1-9]|[1-9]\\d)|3(?:[3569][02-46-9]|4[2-4679]|7[2-467]|8[2-46-8])","[24-6]|[7-9](?:\\d[1-9]|[1-9]\\d)|3(?:3(?:0[1-467]|2[127-9]|3[124578]|[46][1246]|7[1257-9]|8[1256]|9[145])|4(?:2[135]|3[1357]|4[13578]|6[1246]|7[1356]|9[1346])|5(?:0[14]|2[1-3589]|3[1357]|4[1246]|6[1-4]|7[1346]|8[13568]|9[1246])|6(?:0[356]|2[1-489]|3[124-6]|4[1347]|6[13]|7[12579]|8[1-356]|9[135])|7(?:2[1-7]|3[1357]|4[145]|6[1-5]|7[1-4])|8(?:21|3[1468]|4[1347]|6[0135-9]|7[1467]|8[136])|9(?:0[12479]|2[1358]|3[1357]|4[134679]|6[1-9]|7[136]|8[147]|9[1468]))"],"0$1","",0],[null,"(3\\d{4})(\\d{1,10})","$1 $2",["3"],"0$1","",0],[null,"(800)(\\d{7,12})","$1 $2",["800"],"0$1","",0],[null,"(177)(99)(\\d{7,8})","$1 $2 $3",["177","1779","17799"],"0$1","",0],[null,"(\\d{3})(\\d)(\\d{4,10})","$1 $2 $3",["(?:18|90)0","180|900[1359]"],"0$1","",0],[null,"(1\\d{2})(\\d{5,11})","$1 $2",["181"],"0$1","",0],[null,"(18\\d{3})(\\d{6})","$1 $2",["185","1850","18500"],"0$1","",0],[null,"(18\\d{2})(\\d{7})","$1 $2",["18[68]"],"0$1","",0],[null,"(18\\d)(\\d{8})","$1 $2",["18[2-579]"],"0$1","",0],[null,"(700)(\\d{4})(\\d{4})","$1 $2 $3",["700"],"0$1","",0]],null,[null,null,"16(?:4\\d{1,10}|[89]\\d{1,11})","\\d{4,14}",null,null,"16412345"],null,null,[null,null,"NA","NA"],[null,null,"18(?:1\\d{5,11}|[2-9]\\d{8})","\\d{8,14}",null,null,"18500123456"],null,[null,null,"11[02]","\\d{3}",null,null,"112"],[null,null,"17799\\d{7,8}","\\d{12,13}",null,null,"177991234567"]],"DJ":[null,[null,null,"[27]\\d{7}","\\d{8}"],[null,null,"2(?:1[2-5]|7[45])\\d{5}","\\d{8}",null,null,"21360003"],[null,null,"77[6-8]\\d{5}","\\d{8}",null,null,"77831001"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"DJ",253,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[78]","\\d{2}",null,null,"17"],[null,null,"NA","NA"]],"DK":[null,[null,null,"[2-9]\\d{7}","\\d{8}"],[null,null,"(?:[2-7]\\d|8[126-9]|9[126-9])\\d{6}","\\d{8}",null,null,"32123456"],[null,null,"(?:[2-7]\\d|8[126-9]|9[126-9])\\d{6}","\\d{8}",null,null,"20123456"],[null,null,"80\\d{6}","\\d{8}",null,null,"80123456"],[null,null,"90\\d{6}","\\d{8}",null,null,"90123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"DK",45,"00",null,null,null,null,null,null,1,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"DM":[null,[null,null,"[57-9]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"767(?:2(?:55|66)|4(?:2[01]|4[0-25-9])|50[0-4])\\d{4}","\\d{7}(?:\\d{3})?",null,null,"7674201234"],[null,null,"767(?:2(?:[234689]5|7[5-7])|31[5-7]|61[2-7])\\d{4}","\\d{10}",null,null,"7672251234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"DM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"767",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"333|9(?:11|99)","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"DO":[null,[null,null,"[589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"8(?:[04]9[2-9]\\d{6}|29(?:2(?:[0-59]\\d|6[04-9]|7[0-27]|8[0237-9])|3(?:[0-35-9]\\d|4[7-9])|[45]\\d{2}|6(?:[0-27-9]\\d|[3-5][1-9]|6[0135-8])|7(?:0[013-9]|[1-37]\\d|4[1-35689]|5[1-4689]|6[1-57-9]|8[1-79]|9[1-8])|8(?:0[146-9]|1[0-48]|[248]\\d|3[1-79]|5[01589]|6[013-68]|7[124-8]|9[0-8])|9(?:[0-24]\\d|3[02-46-9]|5[0-79]|60|7[0169]|8[57-9]|9[02-9]))\\d{4})","\\d{7}(?:\\d{3})?",null,null,"8092345678"],[null,null,"8[024]9[2-9]\\d{6}","\\d{7}(?:\\d{3})?",null,null,"8092345678"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"DO",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"8[024]9",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"DZ":[null,[null,null,"(?:[1-4]|[5-9]\\d)\\d{7}","\\d{8,9}"],[null,null,"(?:1\\d|2[014-79]|3[0-8]|4[0135689])\\d{6}|9619\\d{5}","\\d{8,9}",null,null,"12345678"],[null,null,"(?:5[4-6]|7[7-9])\\d{7}|6(?:[569]\\d|70)\\d{6}","\\d{9}",null,null,"551234567"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"80[3-689]1\\d{5}","\\d{9}",null,null,"808123456"],[null,null,"80[12]1\\d{5}","\\d{9}",null,null,"801123456"],[null,null,"NA","NA"],[null,null,"98[23]\\d{6}","\\d{9}",null,null,"983123456"],"DZ",213,"00","0",null,null,"0",null,null,null,[[null,"([1-4]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1-4]"],"0$1","",0],[null,"([5-8]\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-8]"],"0$1","",0],[null,"(9\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[47]","\\d{2}",null,null,"17"],[null,null,"NA","NA"]],"EC":[null,[null,null,"1\\d{9,10}|[2-8]\\d{7}|9\\d{8}","\\d{7,11}"],[null,null,"[2-7][2-7]\\d{6}","\\d{7,8}",null,null,"22123456"],[null,null,"9(?:39|[4-6][89]|7[7-9]|[89]\\d)\\d{6}","\\d{9}",null,null,"991234567"],[null,null,"1800\\d{6,7}","\\d{10,11}",null,null,"18001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"[2-7]890\\d{4}","\\d{8}",null,null,"28901234"],"EC",593,"00","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{3})(\\d{4})","$1 $2-$3",["[247]|[356][2-8]"],"(0$1)","",0],[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9"],"0$1","",0],[null,"(1800)(\\d{3})(\\d{3,4})","$1 $2 $3",["1"],"$1","",0]],[[null,"(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[247]|[356][2-8]"]],[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["9","9"],"0$1","",0],[null,"(1800)(\\d{3})(\\d{3,4})","$1 $2 $3",["1","1"],"$1","",0]],[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:0[12]|12)|911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"EE":[null,[null,null,"1\\d{3,4}|[3-9]\\d{6,7}|800\\d{6,7}","\\d{4,10}"],[null,null,"(?:3[23589]|4(?:0\\d|[3-8])|6\\d|7[1-9]|88)\\d{5}","\\d{7,8}",null,null,"3212345"],[null,null,"(?:5\\d|8[1-5])\\d{6}|5(?:[02]\\d{2}|1(?:[0-8]\\d|95)|5[0-478]\\d|64[0-4]|65[1-589])\\d{3}","\\d{7,8}",null,null,"51234567"],[null,null,"800(?:0\\d{3}|1\\d|[2-9])\\d{3}","\\d{7,10}",null,null,"80012345"],[null,null,"900\\d{4}","\\d{7}",null,null,"9001234"],[null,null,"NA","NA"],[null,null,"70[0-2]\\d{5}","\\d{8}",null,null,"70012345"],[null,null,"NA","NA"],"EE",372,"00",null,null,null,null,null,null,null,[[null,"([3-79]\\d{2})(\\d{4})","$1 $2",["[369]|4[3-8]|5(?:[0-2]|5[0-478]|6[45])|7[1-9]","[369]|4[3-8]|5(?:[02]|1(?:[0-8]|95)|5[0-478]|6(?:4[0-4]|5[1-589]))|7[1-9]"],"","",0],[null,"(70)(\\d{2})(\\d{4})","$1 $2 $3",["70"],"","",0],[null,"(8000)(\\d{3})(\\d{3})","$1 $2 $3",["800","8000"],"","",0],[null,"([458]\\d{3})(\\d{3,4})","$1 $2",["40|5|8(?:00|[1-5])","40|5|8(?:00[1-9]|[1-5])"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"1\\d{3,4}|800[2-9]\\d{3}","\\d{4,7}",null,null,"8002123"],[null,null,"1(?:2[01245]|3[0-6]|4[1-489]|5[0-59]|6[1-46-9]|7[0-27-9]|8[189]|9[012])\\d{1,2}","\\d{4,5}",null,null,"12123"],null,[null,null,"11[02]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"EG":[null,[null,null,"1\\d{4,9}|[2456]\\d{8}|3\\d{7}|[89]\\d{8,9}","\\d{5,10}"],[null,null,"(?:1(3[23]\\d|5[23])|2[2-4]\\d{2}|3\\d{2}|4(?:0[2-5]|[578][23]|64)\\d|5(?:0[2-7]|[57][23])\\d|6[24-689]3\\d|8(?:2[2-57]|4[26]|6[237]|8[2-4])\\d|9(?:2[27]|3[24]|52|6[2356]|7[2-4])\\d)\\d{5}|1[69]\\d{3}","\\d{5,9}",null,null,"234567890"],[null,null,"1(?:0[01269]|1[1245]|2[0-278])\\d{7}","\\d{10}",null,null,"1001234567"],[null,null,"800\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"900\\d{7}","\\d{10}",null,null,"9001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"EG",20,"00","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{7,8})","$1 $2",["[23]"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1[012]|[89]00"],"0$1","",0],[null,"(\\d{2})(\\d{6,7})","$1 $2",["1(?:3|5[23])|[4-6]|[89][2-9]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:2[23]|80)","\\d{3}",null,null,"122"],[null,null,"NA","NA"]],"EH":[null,[null,null,"[5689]\\d{8}","\\d{9}"],[null,null,"528[89]\\d{5}","\\d{9}",null,null,"528812345"],[null,null,"6(?:0[0-8]|[124-7]\\d|3[03-8]|8[01]|99)\\d{6}","\\d{9}",null,null,"650123456"],[null,null,"80\\d{7}","\\d{9}",null,null,"801234567"],[null,null,"89\\d{7}","\\d{9}",null,null,"891234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"EH",212,"00","0",null,null,"0",null,null,null,null,null,[null,null,"NA","NA"],null,"528[89]",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:[59]|77)","\\d{2,3}",null,null,"15"],[null,null,"NA","NA"]],"ER":[null,[null,null,"[178]\\d{6}","\\d{6,7}"],[null,null,"1(?:1[12568]|20|40|55|6[146])\\d{4}|8\\d{6}","\\d{6,7}",null,null,"8370362"],[null,null,"17[1-3]\\d{4}|7\\d{6}","\\d{7}",null,null,"7123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"ER",291,"00","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"ES":[null,[null,null,"[5-9]\\d{8}","\\d{9}"],[null,null,"8(?:[13]0|[28][0-8]|[47][1-9]|5[01346-9]|6[0457-9])\\d{6}|9(?:[1238][0-8]\\d{6}|4[1-9]\\d{6}|5\\d{7}|6(?:[0-8]\\d{6}|9(?:0(?:[0-57-9]\\d{4}|6(?:0[0-8]|1[1-9]|[2-9]\\d)\\d{2})|[1-9]\\d{5}))|7(?:[124-9]\\d{2}|3(?:[0-8]\\d|9[1-9]))\\d{4})","\\d{9}",null,null,"810123456"],[null,null,"(?:6\\d{6}|7[1-4]\\d{5}|9(?:6906(?:09|10)|7390\\d{2}))\\d{2}","\\d{9}",null,null,"612345678"],[null,null,"[89]00\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"80[367]\\d{6}","\\d{9}",null,null,"803123456"],[null,null,"90[12]\\d{6}","\\d{9}",null,null,"901123456"],[null,null,"70\\d{7}","\\d{9}",null,null,"701234567"],[null,null,"NA","NA"],"ES",34,"00",null,null,null,null,null,null,null,[[null,"([5-9]\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"51\\d{7}","\\d{9}",null,null,"511234567"],null,[null,null,"0(?:[69][12]|8[05])|112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"ET":[null,[null,null,"[1-59]\\d{8}","\\d{7,9}"],[null,null,"(?:11(?:1(?:1[124]|2[2-57]|3[1-5]|5[5-8]|8[6-8])|2(?:13|3[6-8]|5[89]|7[05-9]|8[2-6])|3(?:2[01]|3[0-289]|4[1289]|7[1-4]|87)|4(?:1[69]|3[2-49]|4[0-3]|6[5-8])|5(?:1[57]|44|5[0-4])|6(?:18|2[69]|4[5-7]|5[1-5]|6[0-59]|8[015-8]))|2(?:2(?:11[1-9]|22[0-7]|33\\d|44[1467]|66[1-68])|5(?:11[124-6]|33[2-8]|44[1467]|55[14]|66[1-3679]|77[124-79]|880))|3(?:3(?:11[0-46-8]|22[0-6]|33[0134689]|44[04]|55[0-6]|66[01467])|4(?:44[0-8]|55[0-69]|66[0-3]|77[1-5]))|4(?:6(?:22[0-24-7]|33[1-5]|44[13-69]|55[14-689]|660|88[1-4])|7(?:11[1-9]|22[1-9]|33[13-7]|44[13-6]|55[1-689]))|5(?:7(?:227|55[05]|(?:66|77)[14-8])|8(?:11[149]|22[013-79]|33[0-68]|44[013-8]|550|66[1-5]|77\\d)))\\d{4}","\\d{7,9}",null,null,"111112345"],[null,null,"9(?:[1-3]\\d|5[89])\\d{6}","\\d{9}",null,null,"911234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"ET",251,"00","0",null,null,"0",null,null,null,[[null,"([1-59]\\d)(\\d{3})(\\d{4})","$1 $2 $3",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"9(?:11?|[23]|9[17])","\\d{2,3}",null,null,"991"],[null,null,"NA","NA"]],"FI":[null,[null,null,"1\\d{4,11}|[2-9]\\d{4,10}","\\d{5,12}"],[null,null,"1(?:[3569][1-8]\\d{3,9}|[47]\\d{5,10})|2[1-8]\\d{3,9}|3(?:[1-8]\\d{3,9}|9\\d{4,8})|[5689][1-8]\\d{3,9}","\\d{5,12}",null,null,"1312345678"],[null,null,"4\\d{5,10}|50\\d{4,8}","\\d{6,11}",null,null,"412345678"],[null,null,"800\\d{4,7}","\\d{7,10}",null,null,"8001234567"],[null,null,"[67]00\\d{5,6}","\\d{8,9}",null,null,"600123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"FI",358,"00|99[049]","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{3,7})","$1 $2",["(?:[1-3]00|[6-8]0)"],"0$1","",0],[null,"(\\d{2})(\\d{4,10})","$1 $2",["2[09]|[14]|50|7[135]"],"0$1","",0],[null,"(\\d)(\\d{4,11})","$1 $2",["[25689][1-8]|3"],"0$1","",0]],null,[null,null,"NA","NA"],1,null,[null,null,"[13]00\\d{3,7}|2(?:0(?:0\\d{3,7}|2[023]\\d{1,6}|9[89]\\d{1,6}))|60(?:[12]\\d{5,6}|6\\d{7})|7(?:1\\d{7}|3\\d{8}|5[03-9]\\d{2,7})","\\d{5,10}",null,null,"100123"],[null,null,"[13]0\\d{4,8}|2(?:0(?:[016-8]\\d{3,7}|[2-59]\\d{2,7})|9\\d{4,8})|60(?:[12]\\d{5,6}|6\\d{7})|7(?:1\\d{7}|3\\d{8}|5[03-9]\\d{2,7})","\\d{5,10}",null,null,"10112345"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"FJ":[null,[null,null,"[36-9]\\d{6}|0\\d{10}","\\d{7}(?:\\d{4})?"],[null,null,"(?:3[0-5]|6[25-7]|8[58])\\d{5}","\\d{7}",null,null,"3212345"],[null,null,"(?:7[0-467]|8[3467]|9\\d)\\d{5}","\\d{7}",null,null,"7012345"],[null,null,"0800\\d{7}","\\d{11}",null,null,"08001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"FJ",679,"0(?:0|52)",null,null,null,null,null,"00",null,[[null,"(\\d{3})(\\d{4})","$1 $2",["[36-9]"],"","",0],[null,"(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["0"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"91[17]","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"FK":[null,[null,null,"[2-7]\\d{4}","\\d{5}"],[null,null,"[2-47]\\d{4}","\\d{5}",null,null,"31234"],[null,null,"[56]\\d{4}","\\d{5}",null,null,"51234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"FK",500,"00",null,null,null,null,null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"FM":[null,[null,null,"[39]\\d{6}","\\d{7}"],[null,null,"3[2357]0[1-9]\\d{3}|9[2-6]\\d{5}","\\d{7}",null,null,"3201234"],[null,null,"3[2357]0[1-9]\\d{3}|9[2-7]\\d{5}","\\d{7}",null,null,"3501234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"FM",691,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911|320221","\\d{3}(?:\\d{3})?",null,null,"911"],[null,null,"NA","NA"]],"FO":[null,[null,null,"[2-9]\\d{5}","\\d{6}"],[null,null,"(?:20|[3-4]\\d|8[19])\\d{4}","\\d{6}",null,null,"201234"],[null,null,"(?:2[1-9]|5\\d|7[1-79])\\d{4}","\\d{6}",null,null,"211234"],[null,null,"80[257-9]\\d{3}","\\d{6}",null,null,"802123"],[null,null,"90(?:[1345][15-7]|2[125-7]|99)\\d{2}","\\d{6}",null,null,"901123"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"(?:6[0-36]|88)\\d{4}","\\d{6}",null,null,"601234"],"FO",298,"00",null,null,null,"(10(?:01|[12]0|88))",null,null,null,[[null,"(\\d{6})","$1",null,"","$CC $1",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"FR":[null,[null,null,"[124-9]\\d{8}|3\\d{3}(?:\\d{5})?","\\d{4}(?:\\d{5})?"],[null,null,"[1-5]\\d{8}","\\d{9}",null,null,"123456789"],[null,null,"6\\d{8}|7[5-9]\\d{7}","\\d{9}",null,null,"612345678"],[null,null,"80\\d{7}","\\d{9}",null,null,"801234567"],[null,null,"3\\d{3}|89[1-37-9]\\d{6}","\\d{4}(?:\\d{5})?",null,null,"891123456"],[null,null,"8(?:1[019]|2[0156]|84|90)\\d{6}","\\d{9}",null,null,"810123456"],[null,null,"NA","NA"],[null,null,"9\\d{8}","\\d{9}",null,null,"912345678"],"FR",33,"[04579]0","0",null,null,"0",null,"00",null,[[null,"([1-79])(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["[1-79]"],"0$1","",0],[null,"(8\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["8"],"0 $1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"3\\d{3}","\\d{4}",null,null,"3123"],[null,null,"NA","NA"],null,[null,null,"1(?:[578]|12)","\\d{2,3}",null,null,"112"],[null,null,"NA","NA"]],"GA":[null,[null,null,"0\\d{7}","\\d{8}"],[null,null,"01\\d{6}","\\d{8}",null,null,"01441234"],[null,null,"0[2-7]\\d{6}","\\d{8}",null,null,"06031234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"GA",241,"00",null,null,null,null,null,null,null,[[null,"(0\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"1730|18|13\\d{2}","\\d{2,4}",null,null,"1730"],[null,null,"NA","NA"]],"GB":[null,[null,null,"\\d{7,10}","\\d{4,10}"],[null,null,"2(?:0[01378]|3[0189]|4[017]|8[0-46-9]|9[012])\\d{7}|1(?:(?:1(?:3[0-48]|[46][0-4]|5[012789]|7[0-49]|8[01349])|21[0-7]|31[0-8]|[459]1\\d|61[0-46-9]))\\d{6}|1(?:2(?:0[024-9]|2[3-9]|3[3-79]|4[1-689]|[58][02-9]|6[0-4789]|7[013-9]|9\\d)|3(?:0\\d|[25][02-9]|3[02-579]|[468][0-46-9]|7[1235679]|9[24578])|4(?:0[03-9]|[28][02-5789]|[37]\\d|4[02-69]|5[0-8]|[69][0-79])|5(?:0[1235-9]|2[024-9]|3[015689]|4[02-9]|5[03-9]|6\\d|7[0-35-9]|8[0-468]|9[0-5789])|6(?:0[034689]|2[0-35689]|[38][013-9]|4[1-467]|5[0-69]|6[13-9]|7[0-8]|9[0124578])|7(?:0[0246-9]|2\\d|3[023678]|4[03-9]|5[0-46-9]|6[013-9]|7[0-35-9]|8[024-9]|9[02-9])|8(?:0[35-9]|2[1-5789]|3[02-578]|4[0-578]|5[124-9]|6[2-69]|7\\d|8[02-9]|9[02569])|9(?:0[02-589]|2[02-689]|3[1-5789]|4[2-9]|5[0-579]|6[234789]|7[0124578]|8\\d|9[2-57]))\\d{6}|1(?:2(?:0(?:46[1-4]|87[2-9])|545[1-79]|76(?:2\\d|3[1-8]|6[1-6])|9(?:7(?:2[0-4]|3[2-5])|8(?:2[2-8]|7[0-4789]|8[345])))|3(?:638[2-5]|647[23]|8(?:47[04-9]|64[015789]))|4(?:044[1-7]|20(?:2[23]|8\\d)|6(?:0(?:30|5[2-57]|6[1-8]|7[2-8])|140)|8(?:052|87[123]))|5(?:24(?:3[2-79]|6\\d)|276\\d|6(?:26[06-9]|686))|6(?:06(?:4\\d|7[4-79])|295[567]|35[34]\\d|47(?:24|61)|59(?:5[08]|6[67]|74)|955[0-4])|7(?:26(?:6[13-9]|7[0-7])|442\\d|50(?:2[0-3]|[3-68]2|76))|8(?:27[56]\\d|37(?:5[2-5]|8[239])|84(?:3[2-58]))|9(?:0(?:0(?:6[1-8]|85)|52\\d)|3583|4(?:66[1-8]|9(?:2[01]|81))|63(?:23|3[1-4])|9561))\\d{3}|176888[234678]\\d{2}|16977[23]\\d{3}","\\d{4,10}",null,null,"1212345678"],[null,null,"7(?:[1-4]\\d\\d|5(?:0[0-8]|[13-9]\\d|2[0-35-9])|7(?:0[1-9]|[1-7]\\d|8[02-9]|9[0-689])|8(?:[014-9]\\d|[23][0-8])|9(?:[04-9]\\d|1[02-9]|2[0-35-9]|3[0-689]))\\d{6}","\\d{10}",null,null,"7400123456"],[null,null,"80(?:0(?:1111|\\d{6,7})|8\\d{7})|500\\d{6}","\\d{7}(?:\\d{2,3})?",null,null,"8001234567"],[null,null,"(?:87[123]|9(?:[01]\\d|8[2349]))\\d{7}","\\d{10}",null,null,"9012345678"],[null,null,"8(?:4(?:5464\\d|[2-5]\\d{7})|70\\d{7})","\\d{7}(?:\\d{3})?",null,null,"8431234567"],[null,null,"70\\d{8}","\\d{10}",null,null,"7012345678"],[null,null,"56\\d{8}","\\d{10}",null,null,"5612345678"],"GB",44,"00","0"," x",null,"0",null,null,null,[[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["2|5[56]|7(?:0|6[013-9])","2|5[56]|7(?:0|6(?:[013-9]|2[0-35-9]))"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:1|\\d1)|3|9[018]"],"0$1","",0],[null,"(\\d{5})(\\d{4,5})","$1 $2",["1(?:38|5[23]|69|76|94)","1(?:387|5(?:24|39)|697|768|946)","1(?:3873|5(?:242|39[456])|697[347]|768[347]|9467)"],"0$1","",0],[null,"(1\\d{3})(\\d{5,6})","$1 $2",["1"],"0$1","",0],[null,"(7\\d{3})(\\d{6})","$1 $2",["7(?:[1-5789]|62)","7(?:[1-5789]|624)"],"0$1","",0],[null,"(800)(\\d{4})","$1 $2",["800","8001","80011","800111","8001111"],"0$1","",0],[null,"(845)(46)(4\\d)","$1 $2 $3",["845","8454","84546","845464"],"0$1","",0],[null,"(8\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8(?:4[2-5]|7[0-3])"],"0$1","",0],[null,"(80\\d)(\\d{3})(\\d{4})","$1 $2 $3",["80"],"0$1","",0],[null,"([58]00)(\\d{6})","$1 $2",["[58]00"],"0$1","",0]],null,[null,null,"76(?:0[012]|2[356]|4[0134]|5[49]|6[0-369]|77|81|9[39])\\d{6}","\\d{10}",null,null,"7640123456"],1,null,[null,null,"NA","NA"],[null,null,"(?:3[0347]|55)\\d{8}","\\d{10}",null,null,"5512345678"],null,[null,null,"112|999","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"GD":[null,[null,null,"[4589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"473(?:2(?:3[0-2]|69)|3(?:2[89]|86)|4(?:[06]8|3[5-9]|4[0-49]|5[5-79]|68|73|90)|63[68]|7(?:58|84)|938)\\d{4}","\\d{7}(?:\\d{3})?",null,null,"4732691234"],[null,null,"473(?:4(?:0[3-79]|1[04-9]|20|58)|53[3-8])\\d{4}","\\d{10}",null,null,"4734031234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"GD",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"473",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"GE":[null,[null,null,"[34578]\\d{8}","\\d{6,9}"],[null,null,"(?:3(?:[256]\\d|4[124-9]|7[0-4])|4(?:1\\d|2[2-7]|3[1-79]|4[2-8]|7[239]|9[1-7]))\\d{6}","\\d{6,9}",null,null,"322123456"],[null,null,"5(?:14|5[01578]|68|7[0147-9]|9[0-35-9])\\d{6}","\\d{9}",null,null,"555123456"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"706\\d{6}","\\d{9}",null,null,"706123456"],"GE",995,"00","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[348]"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["5"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"706\\d{6}","\\d{9}",null,null,"706123456"],[null,null,"NA","NA"],null,[null,null,"0(?:11|22|33)|1(?:1[123]|22)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"GF":[null,[null,null,"[56]\\d{8}","\\d{9}"],[null,null,"594(?:10|2[012457-9]|3[0-57-9]|4[3-9]|5[7-9]|6[0-3]|9[014])\\d{4}","\\d{9}",null,null,"594101234"],[null,null,"694(?:[04][0-7]|1[0-5]|3[018]|[29]\\d)\\d{4}","\\d{9}",null,null,"694201234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"GF",594,"00","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[578]","\\d{2}",null,null,"15"],[null,null,"NA","NA"]],"GG":[null,[null,null,"[135789]\\d{6,9}","\\d{6,10}"],[null,null,"1481\\d{6}","\\d{6,10}",null,null,"1481456789"],[null,null,"7(?:781|839|911)\\d{6}","\\d{10}",null,null,"7781123456"],[null,null,"80(?:0(?:1111|\\d{6,7})|8\\d{7})|500\\d{6}","\\d{7}(?:\\d{2,3})?",null,null,"8001234567"],[null,null,"(?:87[123]|9(?:[01]\\d|8[0-3]))\\d{7}","\\d{10}",null,null,"9012345678"],[null,null,"8(?:4(?:5464\\d|[2-5]\\d{7})|70\\d{7})","\\d{7}(?:\\d{3})?",null,null,"8431234567"],[null,null,"70\\d{8}","\\d{10}",null,null,"7012345678"],[null,null,"56\\d{8}","\\d{10}",null,null,"5612345678"],"GG",44,"00","0"," x",null,"0",null,null,null,null,null,[null,null,"76(?:0[012]|2[356]|4[0134]|5[49]|6[0-369]|77|81|9[39])\\d{6}","\\d{10}",null,null,"7640123456"],null,null,[null,null,"NA","NA"],[null,null,"(?:3[0347]|55)\\d{8}","\\d{10}",null,null,"5512345678"],null,[null,null,"112|999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"GH":[null,[null,null,"[235]\\d{8}|8\\d{7}","\\d{7,9}"],[null,null,"3(?:0[237]\\d|[167](?:2[0-6]|7\\d)|2(?:2[0-5]|7\\d)|3(?:2[0-3]|7\\d)|4(?:2[013-9]|3[01]|7\\d)|5(?:2[0-7]|7\\d)|8(?:2[0-2]|7\\d)|9(?:20|7\\d))\\d{5}","\\d{7,9}",null,null,"302345678"],[null,null,"(?:2[034678]|5[047])\\d{7}","\\d{9}",null,null,"231234567"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"GH",233,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[235]"],"0$1","",0],[null,"(\\d{3})(\\d{5})","$1 $2",["8"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"NA","NA"],null,[null,null,"19[123]|999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"GI":[null,[null,null,"[2568]\\d{7}","\\d{8}"],[null,null,"2(?:00\\d|16[0-7]|22[2457])\\d{4}","\\d{8}",null,null,"20012345"],[null,null,"(?:5[4-8]|60)\\d{6}","\\d{8}",null,null,"57123456"],[null,null,"80\\d{6}","\\d{8}",null,null,"80123456"],[null,null,"8[1-689]\\d{6}","\\d{8}",null,null,"88123456"],[null,null,"87\\d{6}","\\d{8}",null,null,"87123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],"GI",350,"00",null,null,null,null,null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:12|9[09])","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"GL":[null,[null,null,"[1-689]\\d{5}","\\d{6}"],[null,null,"(?:19|3[1-6]|6[14689]|8[14-79]|9\\d)\\d{4}","\\d{6}",null,null,"321000"],[null,null,"[245][2-9]\\d{4}","\\d{6}",null,null,"221234"],[null,null,"80\\d{4}","\\d{6}",null,null,"801234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"3[89]\\d{4}","\\d{6}",null,null,"381234"],"GL",299,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"GM":[null,[null,null,"[2-9]\\d{6}","\\d{7}"],[null,null,"(?:4(?:[23]\\d{2}|4(?:1[024679]|[6-9]\\d))|5(?:54[0-7]|6(?:[67]\\d)|7(?:1[04]|2[035]|3[58]|48))|8\\d{3})\\d{3}","\\d{7}",null,null,"5661234"],[null,null,"(?:2[0-2]|[3679]\\d)\\d{5}","\\d{7}",null,null,"3012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"GM",220,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1?1[678]","\\d{2,3}",null,null,"117"],[null,null,"NA","NA"]],"GN":[null,[null,null,"[367]\\d{7,8}","\\d{8,9}"],[null,null,"30(?:24|3[12]|4[1-35-7]|5[13]|6[189]|[78]1|9[1478])\\d{4}","\\d{8}",null,null,"30241234"],[null,null,"6(?:[03]1|2[128]|5[57]|6[2469])\\d{6}","\\d{9}",null,null,"601123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"722\\d{6}","\\d{9}",null,null,"722123456"],"GN",224,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["3"],"","",0],[null,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[67]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"GP":[null,[null,null,"[56]\\d{8}","\\d{9}"],[null,null,"590(?:0[13468]|1[012]|2[0-68]|3[28]|4[0-8]|5[579]|6[0189]|70|8[0-689]|9\\d)\\d{4}","\\d{9}",null,null,"590201234"],[null,null,"690(?:0[0-7]|[1-9]\\d)\\d{4}","\\d{9}",null,null,"690301234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"GP",590,"00","0",null,null,"0",null,null,null,[[null,"([56]90)(\\d{2})(\\d{4})","$1 $2-$3",null,"0$1","",0]],null,[null,null,"NA","NA"],1,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[578]","\\d{2}",null,null,"18"],[null,null,"NA","NA"]],"GQ":[null,[null,null,"[23589]\\d{8}","\\d{9}"],[null,null,"3(?:3(?:3\\d[7-9]|[0-24-9]\\d[46])|5\\d{2}[7-9])\\d{4}","\\d{9}",null,null,"333091234"],[null,null,"(?:222|551)\\d{6}","\\d{9}",null,null,"222123456"],[null,null,"80\\d[1-9]\\d{5}","\\d{9}",null,null,"800123456"],[null,null,"90\\d[1-9]\\d{5}","\\d{9}",null,null,"900123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"GQ",240,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[235]"],"","",0],[null,"(\\d{3})(\\d{6})","$1 $2",["[89]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"GR":[null,[null,null,"[26-9]\\d{9}","\\d{10}"],[null,null,"2(?:1\\d{2}|2(?:3[1-8]|4[1-7]|5[1-4]|6[1-8]|7[1-5]|[289][1-9])|3(?:1\\d|2[1-57]|3[1-4]|[45][1-3]|7[1-7]|8[1-6]|9[1-79])|4(?:1\\d|2[1-8]|3[1-4]|4[13-5]|6[1-578]|9[1-5])|5(?:1\\d|[239][1-4]|4[124]|5[1-6])|6(?:1\\d|3[124]|4[1-7]|5[13-9]|[269][1-6]|7[14]|8[1-5])|7(?:1\\d|2[1-5]|3[1-6]|4[1-7]|5[1-57]|6[134]|9[15-7])|8(?:1\\d|2[1-5]|[34][1-4]|9[1-7]))\\d{6}","\\d{10}",null,null,"2123456789"],[null,null,"69\\d{8}","\\d{10}",null,null,"6912345678"],[null,null,"800\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"90[19]\\d{7}","\\d{10}",null,null,"9091234567"],[null,null,"8(?:0[16]|12|25)\\d{7}","\\d{10}",null,null,"8011234567"],[null,null,"70\\d{8}","\\d{10}",null,null,"7012345678"],[null,null,"NA","NA"],"GR",30,"00",null,null,null,null,null,null,null,[[null,"([27]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["21|7"],"","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["2[2-9]1|[689]"],"","",0],[null,"(2\\d{3})(\\d{6})","$1 $2",["2[2-9][02-9]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:00|12|66|99)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"GT":[null,[null,null,"[2-7]\\d{7}|1[89]\\d{9}","\\d{8}(?:\\d{3})?"],[null,null,"[267][2-9]\\d{6}","\\d{8}",null,null,"22456789"],[null,null,"[345]\\d{7}","\\d{8}",null,null,"51234567"],[null,null,"18[01]\\d{8}","\\d{11}",null,null,"18001112222"],[null,null,"19\\d{9}","\\d{11}",null,null,"19001112222"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"GT",502,"00",null,null,null,null,null,null,null,[[null,"(\\d{4})(\\d{4})","$1 $2",["[2-7]"],"","",0],[null,"(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:10|2[03])","\\d{3}",null,null,"110"],[null,null,"NA","NA"]],"GU":[null,[null,null,"[5689]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:56|7[1-9]|8[236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[5-9])|7(?:[079]7|2[0167]|3[45]|8[789])|8(?:[2-5789]8|6[48])|9(?:2[29]|6[79]|7[179]|8[789]|9[78]))\\d{4}","\\d{7}(?:\\d{3})?",null,null,"6713001234"],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:56|7[1-9]|8[236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[5-9])|7(?:[079]7|2[0167]|3[45]|8[789])|8(?:[2-5789]8|6[48])|9(?:2[29]|6[79]|7[179]|8[789]|9[78]))\\d{4}","\\d{7}(?:\\d{3})?",null,null,"6713001234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"GU",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,"NA","NA"],null,"671",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"GW":[null,[null,null,"[3-79]\\d{6}","\\d{7}"],[null,null,"3(?:2[0125]|3[1245]|4[12]|5[1-4]|70|9[1-467])\\d{4}","\\d{7}",null,null,"3201234"],[null,null,"(?:[5-7]\\d|9[012])\\d{5}","\\d{7}",null,null,"5012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"40\\d{5}","\\d{7}",null,null,"4012345"],"GW",245,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[378]","\\d{3}",null,null,"113"],[null,null,"NA","NA"]],"GY":[null,[null,null,"[2-4679]\\d{6}","\\d{7}"],[null,null,"(?: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}","\\d{7}",null,null,"2201234"],[null,null,"6\\d{6}","\\d{7}",null,null,"6091234"],[null,null,"(?:289|862)\\d{4}","\\d{7}",null,null,"2891234"],[null,null,"9008\\d{3}","\\d{7}",null,null,"9008123"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"GY",592,"001",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"91[123]","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"HK":[null,[null,null,"[235-7]\\d{7}|8\\d{7,8}|9\\d{4,10}","\\d{5,11}"],[null,null,"(?:[23]\\d|5[78])\\d{6}","\\d{8}",null,null,"21234567"],[null,null,"(?:5[1-69]\\d|6\\d{2}|9(?:0[1-9]|[1-8]\\d))\\d{5}","\\d{8}",null,null,"51234567"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"900(?:[0-24-9]\\d{7}|3\\d{1,4})","\\d{5,11}",null,null,"90012345678"],[null,null,"NA","NA"],[null,null,"8[1-3]\\d{6}","\\d{8}",null,null,"81123456"],[null,null,"NA","NA"],"HK",852,"00",null,null,null,null,null,null,null,[[null,"(\\d{4})(\\d{4})","$1 $2",["[235-7]|[89](?:0[1-9]|[1-9])"],"","",0],[null,"(800)(\\d{3})(\\d{3})","$1 $2 $3",["800"],"","",0],[null,"(900)(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["900"],"","",0],[null,"(900)(\\d{2,5})","$1 $2",["900"],"","",0]],null,[null,null,"7\\d{7}","\\d{8}",null,null,"71234567"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|99[29]","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"HN":[null,[null,null,"[237-9]\\d{7}","\\d{8}"],[null,null,"2(?:2(?:0[019]|1[1-36]|[23]\\d|4[056]|5[57]|7[01389]|8[0146-9]|9[012])|4(?:2[3-59]|3[13-689]|4[0-68]|5[1-35])|5(?:4[3-5]|5\\d|6[56]|74)|6(?:4[0-378]|[56]\\d|[78][0-8]|9[01])|7(?:6[46-9]|7[02-9]|8[34])|8(?:79|8[0-35789]|9[1-57-9]))\\d{4}","\\d{8}",null,null,"22123456"],[null,null,"[37-9]\\d{7}","\\d{8}",null,null,"91234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"HN",504,"00",null,null,null,null,null,null,null,[[null,"(\\d{4})(\\d{4})","$1-$2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"199","\\d{3}",null,null,"199"],[null,null,"NA","NA"]],"HR":[null,[null,null,"[1-7]\\d{5,8}|[89]\\d{6,11}","\\d{6,12}"],[null,null,"1\\d{7}|(?:2[0-3]|3[1-5]|4[02-47-9]|5[1-3])\\d{6}","\\d{6,8}",null,null,"12345678"],[null,null,"9[1257-9]\\d{6,10}","\\d{8,12}",null,null,"912345678"],[null,null,"80[01]\\d{4,7}","\\d{7,10}",null,null,"8001234567"],[null,null,"6(?:[09]\\d{7}|[145]\\d{4,7})","\\d{6,9}",null,null,"611234"],[null,null,"NA","NA"],[null,null,"7[45]\\d{4,7}","\\d{6,9}",null,null,"741234567"],[null,null,"NA","NA"],"HR",385,"00","0",null,null,"0",null,null,null,[[null,"(1)(\\d{4})(\\d{3})","$1 $2 $3",["1"],"0$1","",0],[null,"(6[09])(\\d{4})(\\d{3})","$1 $2 $3",["6[09]"],"0$1","",0],[null,"(62)(\\d{3})(\\d{3,4})","$1 $2 $3",["62"],"0$1","",0],[null,"([2-5]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[2-5]"],"0$1","",0],[null,"(9\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["9"],"0$1","",0],[null,"(9\\d)(\\d{4})(\\d{4})","$1 $2 $3",["9"],"0$1","",0],[null,"(9\\d)(\\d{3,4})(\\d{3})(\\d{3})","$1 $2 $3 $4",["9"],"0$1","",0],[null,"(\\d{2})(\\d{2})(\\d{2,3})","$1 $2 $3",["6[145]|7"],"0$1","",0],[null,"(\\d{2})(\\d{3,4})(\\d{3})","$1 $2 $3",["6[145]|7"],"0$1","",0],[null,"(80[01])(\\d{2})(\\d{2,3})","$1 $2 $3",["8"],"0$1","",0],[null,"(80[01])(\\d{3,4})(\\d{3})","$1 $2 $3",["8"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"62\\d{6,7}","\\d{8,9}",null,null,"62123456"],null,[null,null,"1(?:12|92)|9[34]","\\d{2,3}",null,null,"112"],[null,null,"NA","NA"]],"HT":[null,[null,null,"[2-489]\\d{7}","\\d{8}"],[null,null,"2(?:[24]\\d|5[1-5]|94)\\d{5}","\\d{8}",null,null,"22453300"],[null,null,"(?:3[1-9]|4\\d)\\d{6}","\\d{8}",null,null,"34101234"],[null,null,"8\\d{7}","\\d{8}",null,null,"80012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"98[89]\\d{5}","\\d{8}",null,null,"98901234"],"HT",509,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[48]","\\d{3}",null,null,"118"],[null,null,"NA","NA"]],"HU":[null,[null,null,"[1-9]\\d{7,8}","\\d{6,9}"],[null,null,"(?:1\\d|2(?:1\\d|[2-9])|3[2-7]|4[24-9]|5[2-79]|6[23689]|7(?:1\\d|[2-9])|8[2-57-9]|9[2-69])\\d{6}","\\d{6,9}",null,null,"12345678"],[null,null,"(?:[27]0|3[01])\\d{7}","\\d{9}",null,null,"201234567"],[null,null,"80\\d{6}","\\d{8}",null,null,"80123456"],[null,null,"9[01]\\d{6}","\\d{8}",null,null,"90123456"],[null,null,"40\\d{6}","\\d{8}",null,null,"40123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],"HU",36,"00","06",null,null,"06",null,null,null,[[null,"(1)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"($1)","",0],[null,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-9]"],"($1)","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:0[457]|12)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"ID":[null,[null,null,"[1-9]\\d{6,10}","\\d{5,11}"],[null,null,"2(?:1(?:[0-8]\\d{6,7}|9\\d{6})|[24]\\d{7,8})|(?:2(?:[35][1-4]|6[0-8]|7[1-6]|8\\d|9[1-8])|3(?:1|2[1-578]|3[1-68]|4[1-3]|5[1-8]|6[1-3568]|7[0-46]|8\\d)|4(?:0[1-589]|1[01347-9]|2[0-36-8]|3[0-24-68]|5[1-378]|6[1-5]|7[134]|8[1245])|5(?:1[1-35-9]|2[25-8]|3[1246-9]|4[1-3589]|5[1-46]|6[1-8])|6(?:19?|[25]\\d|3[1-469]|4[1-6])|7(?:1[1-46-9]|2[14-9]|[36]\\d|4[1-8]|5[1-9]|7[0-36-9])|9(?:0[12]|1[013-8]|2[0-479]|5[125-8]|6[23679]|7[159]|8[01346]))\\d{5,8}","\\d{5,10}",null,null,"612345678"],[null,null,"(?:2(?:1(?:3[145]|4[01]|5[1-469]|60|8[0359]|9\\d)|2(?:88|9[1256])|3[1-4]9|4(?:36|91)|5(?:1[349]|[2-4]9)|6[0-7]9|7(?:[1-36]9|4[39])|8[1-5]9|9[1-48]9)|3(?:19[1-3]|2[12]9|3[13]9|4(?:1[69]|39)|5[14]9|6(?:1[69]|2[89])|709)|4[13]19|5(?:1(?:19|8[39])|4[129]9|6[12]9)|6(?:19[12]|2(?:[23]9|77))|7(?:1[13]9|2[15]9|419|5(?:1[89]|29)|6[15]9|7[178]9))\\d{5,6}|8[1-35-9]\\d{7,9}","\\d{9,11}",null,null,"812345678"],[null,null,"177\\d{6,8}|800\\d{5,7}","\\d{8,11}",null,null,"8001234567"],[null,null,"809\\d{7}","\\d{10}",null,null,"8091234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"ID",62,"0(?:0[1789]|10(?:00|1[67]))","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{7,8})","$1 $2",["2[124]|[36]1"],"(0$1)","",0],[null,"(\\d{3})(\\d{5,7})","$1 $2",["[4579]|2[035-9]|[36][02-9]"],"(0$1)","",0],[null,"(8\\d{2})(\\d{3,4})(\\d{3,4})","$1-$2-$3",["8[1-35-9]"],"0$1","",0],[null,"(177)(\\d{6,8})","$1 $2",["1"],"0$1","",0],[null,"(800)(\\d{5,7})","$1 $2",["800"],"0$1","",0],[null,"(809)(\\d)(\\d{3})(\\d{3})","$1 $2 $3 $4",["809"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[02389]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"IE":[null,[null,null,"[124-9]\\d{6,9}","\\d{5,10}"],[null,null,"1\\d{7,8}|2(?:1\\d{6,7}|3\\d{7}|[24-9]\\d{5})|4(?:0[24]\\d{5}|[1-469]\\d{7}|5\\d{6}|7\\d{5}|8[0-46-9]\\d{7})|5(?:0[45]\\d{5}|1\\d{6}|[23679]\\d{7}|8\\d{5})|6(?:1\\d{6}|[237-9]\\d{5}|[4-6]\\d{7})|7[14]\\d{7}|9(?:1\\d{6}|[04]\\d{7}|[35-9]\\d{5})","\\d{5,10}",null,null,"2212345"],[null,null,"8(?:22\\d{6}|[35-9]\\d{7})","\\d{9}",null,null,"850123456"],[null,null,"1800\\d{6}","\\d{10}",null,null,"1800123456"],[null,null,"15(?:1[2-8]|[2-8]0|9[089])\\d{6}","\\d{10}",null,null,"1520123456"],[null,null,"18[59]0\\d{6}","\\d{10}",null,null,"1850123456"],[null,null,"700\\d{6}","\\d{9}",null,null,"700123456"],[null,null,"76\\d{7}","\\d{9}",null,null,"761234567"],"IE",353,"00","0",null,null,"0",null,null,null,[[null,"(1)(\\d{3,4})(\\d{4})","$1 $2 $3",["1"],"(0$1)","",0],[null,"(\\d{2})(\\d{5})","$1 $2",["2[24-9]|47|58|6[237-9]|9[35-9]"],"(0$1)","",0],[null,"(\\d{3})(\\d{5})","$1 $2",["40[24]|50[45]"],"(0$1)","",0],[null,"(48)(\\d{4})(\\d{4})","$1 $2 $3",["48"],"(0$1)","",0],[null,"(818)(\\d{3})(\\d{3})","$1 $2 $3",["81"],"(0$1)","",0],[null,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[24-69]|7[14]"],"(0$1)","",0],[null,"([78]\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["76|8[35-9]"],"0$1","",0],[null,"(700)(\\d{3})(\\d{3})","$1 $2 $3",["70"],"0$1","",0],[null,"(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:8[059]|5)","1(?:8[059]0|5)"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"18[59]0\\d{6}","\\d{10}",null,null,"1850123456"],[null,null,"818\\d{6}","\\d{9}",null,null,"818123456"],null,[null,null,"112|999","\\d{3}",null,null,"112"],[null,null,"8[35-9]\\d{8}","\\d{10}",null,null,"8501234567"]],"IL":[null,[null,null,"[17]\\d{6,9}|[2-589]\\d{3}(?:\\d{3,6})?|6\\d{3}","\\d{4,10}"],[null,null,"[2-489]\\d{7}","\\d{7,8}",null,null,"21234567"],[null,null,"5(?:[02347-9]\\d{2}|5(?:2[23]|3[34]|4[45]|5[5689]|6[67]|7[78]|8[89])|6[2-9]\\d)\\d{5}","\\d{9}",null,null,"501234567"],[null,null,"1(?:80[019]\\d{3}|255)\\d{3}","\\d{7,10}",null,null,"1800123456"],[null,null,"1(?:212|(?:9(?:0[01]|19)|200)\\d{2})\\d{4}","\\d{8,10}",null,null,"1919123456"],[null,null,"1700\\d{6}","\\d{10}",null,null,"1700123456"],[null,null,"NA","NA"],[null,null,"7(?:2[23]\\d|3[237]\\d|47\\d|6(?:5\\d|8[08])|7\\d{2}|8(?:33|55|77|81))\\d{5}","\\d{9}",null,null,"771234567"],"IL",972,"0(?:0|1[2-9])","0",null,null,"0",null,null,null,[[null,"([2-489])(\\d{3})(\\d{4})","$1-$2-$3",["[2-489]"],"0$1","",0],[null,"([57]\\d)(\\d{3})(\\d{4})","$1-$2-$3",["[57]"],"0$1","",0],[null,"(1)([7-9]\\d{2})(\\d{3})(\\d{3})","$1-$2-$3-$4",["1[7-9]"],"$1","",0],[null,"(1255)(\\d{3})","$1-$2",["125"],"$1","",0],[null,"(1200)(\\d{3})(\\d{3})","$1-$2-$3",["120"],"$1","",0],[null,"(1212)(\\d{2})(\\d{2})","$1-$2-$3",["121"],"$1","",0],[null,"(1599)(\\d{6})","$1-$2",["15"],"$1","",0],[null,"(\\d{4})","*$1",["[2-689]"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"1700\\d{6}|[2-689]\\d{3}","\\d{4,10}",null,null,"1700123456"],[null,null,"[2-689]\\d{3}|1599\\d{6}","\\d{4}(?:\\d{6})?",null,null,"1599123456"],null,[null,null,"1(?:0[012]|12)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"IM":[null,[null,null,"[135789]\\d{6,9}","\\d{6,10}"],[null,null,"1624\\d{6}","\\d{6,10}",null,null,"1624456789"],[null,null,"7[569]24\\d{6}","\\d{10}",null,null,"7924123456"],[null,null,"808162\\d{4}","\\d{10}",null,null,"8081624567"],[null,null,"(?:872299|90[0167]624)\\d{4}","\\d{10}",null,null,"9016247890"],[null,null,"8(?:4(?:40[49]06|5624\\d)|70624\\d)\\d{3}","\\d{10}",null,null,"8456247890"],[null,null,"70\\d{8}","\\d{10}",null,null,"7012345678"],[null,null,"56\\d{8}","\\d{10}",null,null,"5612345678"],"IM",44,"00","0"," x",null,"0",null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"3(?:08162\\d|3\\d{5}|4(?:40[49]06|5624\\d)|7(?:0624\\d|2299\\d))\\d{3}|55\\d{8}","\\d{10}",null,null,"5512345678"],null,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"IN":[null,[null,null,"1\\d{7,12}|[2-9]\\d{9,10}","\\d{6,13}"],[null,null,"(?:11|2[02]|33|4[04]|79)[2-7]\\d{7}|80[2-467]\\d{7}|(?:1(?:2[0-249]|3[0-25]|4[145]|[59][14]|6[014]|7[1257]|8[01346])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[126-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:[136][25]|22|4[28]|5[12]|[78]1|9[15])|6(?:12|[2345]1|57|6[13]|7[14]|80)|7(?:12|2[14]|3[134]|4[47]|5[15]|[67]1|88)|8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91))[2-7]\\d{6}|(?:(?:1(?:2[35-8]|3[346-9]|4[236-9]|[59][0235-9]|6[235-9]|7[34689]|8[257-9])|2(?:1[134689]|3[24-8]|4[2-8]|5[25689]|6[2-4679]|7[13-79]|8[2-479]|9[235-9])|3(?:01|1[79]|2[1-5]|4[25-8]|5[125689]|6[235-7]|7[157-9]|8[2-467])|4(?:1[14578]|2[5689]|3[2-467]|5[4-7]|6[35]|73|8[2689]|9[2389])|5(?:[16][146-9]|2[14-8]|3[1346]|4[14-69]|5[46]|7[2-4]|8[2-8]|9[246])|6(?:1[1358]|2[2457]|3[2-4]|4[235-7]|[57][2-689]|6[24-58]|8[1-6])|8(?:1[1357-9]|2[235-8]|3[03-57-9]|4[0-24-9]|5\\d|6[2457-9]|7[1-6]|8[1256]|9[2-4]))\\d|7(?:(?:1[013-9]|2[0235-9]|3[2679]|4[1-35689]|5[2-46-9]|[67][02-9]|9\\d)\\d|8(?:2[0-6]|[013-8]\\d)))[2-7]\\d{5}","\\d{6,10}",null,null,"1123456789"],[null,null,"(?:7(?:2(?:0[04-9]|5[09]|7[5-8]|9[389])|3(?:0[1-9]|[58]\\d|7[3679]|9[689])|4(?:0[1-9]|1[15-9]|[29][89]|39|8[389])|5(?:0\\d|[47]9|[25]0|6[6-9]|[89][7-9])|6(?:0[027]|12|20|3[19]|5[45]|6[5-9]|7[679]|9[1-46-9])|7(?:0[2-9]|[1-79]\\d|8[1-9])|8(?:[0-7]\\d|9[013-9]))|8(?:0(?:[01589]\\d|6[67])|1(?:[02-589]\\d|1[0135-9]|7[0-79])|2(?:[236-9]\\d|5[1-9])|3(?:[0357-9]\\d|4[1-9])|[45]\\d{2}|6[02457-9]\\d|7[1-69]\\d|8(?:[0-26-9]\\d|44|5[2-9])|9(?:[035-9]\\d|2[2-9]|4[0-8]))|9\\d{3})\\d{6}","\\d{10}",null,null,"9123456789"],[null,null,"1(?:600\\d{6}|80(?:0\\d{4,8}|3\\d{9}))","\\d{8,13}",null,null,"1800123456"],[null,null,"186[12]\\d{9}","\\d{13}",null,null,"1861123456789"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"IN",91,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{6})","$1 $2 $3",["7(?:2[0579]|3[057-9]|4[0-389]|5[024-9]|6[0-35-9]|7|8[0-79])|8(?:0[015689]|1[0-57-9]|2[2356-9]|3[0-57-9]|[45]|6[0245789]|7[1-69]|8[0124-9]|9[02-9])|9","7(?:2(?:0[04-9]|5[09]|7[5-8]|9[389])|3(?:0[1-9]|[58]|7[3679]|9[689])|4(?:0[1-9]|1[15-9]|[29][89]|39|8[389])|5(?:0|[47]9|[25]0|6[6-9]|[89][7-9])|6(?:0[027]|12|20|3[19]|5[45]|6[5-9]|7[679]|9[1-46-9])|7(?:0[2-9]|[1-79]|8[1-9])|8(?:[0-7]|9[013-9]))|8(?:0(?:[01589]|6[67])|1(?:[02-589]|1[0135-9]|7[0-79])|2(?:[236-9]|5[1-9])|3(?:[0357-9]|4[1-9])|[45]|6[02457-9]|7[1-69]|8(?:[0-26-9]|44|5[2-9])|9(?:[035-9]|2[2-9]|4[0-8]))|9"],"0$1","",1],[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["11|2[02]|33|4[04]|79|80[2-46]"],"0$1","",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1(?:2[0-249]|3[0-25]|4[145]|[569][14]|7[1257]|8[1346]|[68][1-9])|2(?:1[257]|3[013]|4[01]|5[0137]|6[0158]|78|8[1568]|9[14])|3(?:26|4[1-3]|5[34]|6[01489]|7[02-46]|8[159])|4(?:1[36]|2[1-47]|3[15]|5[12]|6[126-9]|7[0-24-9]|8[013-57]|9[014-7])|5(?:[136][25]|22|4[28]|5[12]|[78]1|9[15])|6(?:12|[2345]1|57|6[13]|7[14]|80)"],"0$1","",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["7(?:12|2[14]|3[134]|4[47]|5[15]|[67]1|88)","7(?:12|2[14]|3[134]|4[47]|5(?:1|5[2-6])|[67]1|88)"],"0$1","",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8(?:16|2[014]|3[126]|6[136]|7[078]|8[34]|91)"],"0$1","",1],[null,"(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1(?:[2-579]|[68][1-9])|[2-8]"],"0$1","",1],[null,"(1600)(\\d{2})(\\d{4})","$1 $2 $3",["160","1600"],"$1","",0],[null,"(1800)(\\d{4,5})","$1 $2",["180","1800"],"$1","",0],[null,"(18[06]0)(\\d{2,4})(\\d{4})","$1 $2 $3",["18[06]","18[06]0"],"$1","",0],[null,"(\\d{4})(\\d{3})(\\d{4})(\\d{2})","$1 $2 $3 $4",["18[06]","18(?:03|6[12])"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"1(?:600\\d{6}|8(?:0(?:0\\d{4,8}|3\\d{9})|6(?:0\\d{7}|[12]\\d{9})))","\\d{8,13}",null,null,"1800123456"],[null,null,"1860\\d{7}","\\d{11}",null,null,"18603451234"],null,[null,null,"1(?:0[0128]|12|298)|2611","\\d{3,4}",null,null,"108"],[null,null,"NA","NA"]],"IO":[null,[null,null,"3\\d{6}","\\d{7}"],[null,null,"37\\d{5}","\\d{7}",null,null,"3709100"],[null,null,"38\\d{5}","\\d{7}",null,null,"3801234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"IO",246,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"IQ":[null,[null,null,"[1-7]\\d{7,9}","\\d{6,10}"],[null,null,"1\\d{7}|(?:2[13-5]|3[02367]|4[023]|5[03]|6[026])\\d{6,7}","\\d{6,9}",null,null,"12345678"],[null,null,"7[3-9]\\d{8}","\\d{10}",null,null,"7912345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"IQ",964,"00","0",null,null,"0",null,null,null,[[null,"(1)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1","",0],[null,"([2-6]\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[2-6]"],"0$1","",0],[null,"(7\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"IR":[null,[null,null,"[14-8]\\d{6,9}|[23]\\d{4,9}|9(?:[1-4]\\d{8}|9\\d{2,8})","\\d{4,10}"],[null,null,"1(?:[13-589][12]|[27][1-4])\\d{7}|2(?:1\\d{3,8}|3[12]\\d{7}|4(?:1\\d{4,7}|2\\d{7})|5(?:1\\d{3,7}|[2356]\\d{7})|6\\d{8}|7[34]\\d{7}|[89][12]\\d{7})|3(?:1(?:1\\d{4,7}|2\\d{7})|2[1-4]\\d{7}|3(?:[125]\\d{7}|4\\d{6,7})|4(?:1\\d{6,7}[24-9]\\d{7})|5(?:1\\d{4,7}|[23]\\d{7})|[6-9][12]\\d{7})|4(?:[135-9][12]\\d{7}|2[1-467]\\d{7}|4(?:1\\d{4,7}|[2-4]\\d{7}))|5(?:1(?:1\\d{4,7}|2\\d{7})|2[89]\\d{7}|3[1-5]\\d{7}|4(?:1\\d{4,7}|[2-8]\\d{7})|[5-7][12]\\d{7}|8[1245]\\d{7})|6(?:1(?:1\\d{6,7}|2\\d{7})|[347-9][12]\\d{7}|5(?:1\\d{7}|2\\d{6,7})|6[1-6]\\d{7})|7(?:[13589][12]|2[1289]|4[1-4]|6[1-6]|7[1-3])\\d{7}|8(?:[145][12]|3[124578]|6[1256]|7[1245])\\d{7}","\\d{5,10}",null,null,"2123456789"],[null,null,"9[1-3]\\d{8}","\\d{10}",null,null,"9123456789"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"(?:[2-6]0\\d|993)\\d{7}","\\d{10}",null,null,"9932123456"],"IR",98,"00","0",null,null,"0",null,null,null,[[null,"(2[15])(\\d{3,5})","$1 $2",["2(?:1|5[0-47-9])"],"0$1","",0],[null,"(2[15])(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1|5[0-47-9])"],"0$1","",0],[null,"(2\\d)(\\d{4})(\\d{4})","$1 $2 $3",["2(?:[16]|5[0-47-9])"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13-9]|2[02-57-9]"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["[13-9]|2[02-57-9]"],"0$1","",0],[null,"(\\d{3})(\\d{3})","$1 $2",["[13-9]|2[02-57-9]"],"0$1","",0]],null,[null,null,"943\\d{7}","\\d{10}",null,null,"9432123456"],null,null,[null,null,"NA","NA"],[null,null,"9990\\d{0,6}","\\d{4,10}",null,null,"9990123456"],null,[null,null,"1(?:1[025]|25)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"IS":[null,[null,null,"[4-9]\\d{6}|38\\d{7}","\\d{7,9}"],[null,null,"(?:4(?:[14][0-245]|2[0-7]|[37][0-8]|5[0-3568]|6\\d|8[0-36-8])|5(?:05|[156]\\d|2[02578]|3[013-7]|4[03-7]|7[0-2578]|8[0-35-9]|9[013-689])|87[23])\\d{4}","\\d{7}",null,null,"4101234"],[null,null,"38[59]\\d{6}|(?:6(?:1[0-8]|3[0-27-9]|4[0-27]|5[0-29]|[67][0-69]|9\\d)|7(?:5[057]|7\\d|8[0-3])|8(?:2[0-5]|[469]\\d|5[1-9]))\\d{4}","\\d{7,9}",null,null,"6101234"],[null,null,"800\\d{4}","\\d{7}",null,null,"8001234"],[null,null,"90\\d{5}","\\d{7}",null,null,"9011234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"49[0-24-79]\\d{4}","\\d{7}",null,null,"4921234"],"IS",354,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",["[4-9]"],"","",0],[null,"(3\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["3"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"388\\d{6}|(?:6(?:2[0-8]|49|8\\d)|8(?:2[6-9]|[38]\\d|50|7[014-9])|95[48])\\d{4}","\\d{7,9}",null,null,"388123456"]],"IT":[null,[null,null,"[01589]\\d{5,10}|3(?:[12457-9]\\d{8}|[36]\\d{7,9})","\\d{6,11}"],[null,null,"0(?:[26]\\d{4,9}|(?:1(?:[0159]\\d|[27][1-5]|31|4[1-4]|6[1356]|8[2-57])|3(?:[0159]\\d|2[1-4]|3[12]|[48][1-6]|6[2-59]|7[1-7])|4(?:[0159]\\d|[23][1-9]|4[245]|6[1-5]|7[1-4]|81)|5(?:[0159]\\d|2[1-5]|3[2-6]|4[1-79]|6[4-6]|7[1-578]|8[3-8])|7(?:[0159]\\d|2[12]|3[1-7]|4[2346]|6[13569]|7[13-6]|8[1-59])|8(?:[0159]\\d|2[34578]|3[1-356]|[6-8][1-5])|9(?:[0159]\\d|[238][1-5]|4[12]|6[1-8]|7[1-6]))\\d{2,7})","\\d{6,11}",null,null,"0212345678"],[null,null,"3(?:[12457-9]\\d{8}|6\\d{7,8}|3\\d{7,9})","\\d{9,11}",null,null,"3123456789"],[null,null,"80(?:0\\d{6}|3\\d{3})","\\d{6,9}",null,null,"800123456"],[null,null,"0878\\d{5}|1(?:44|6[346])\\d{6}|89(?:2\\d{3}|4(?:[0-4]\\d{2}|[5-9]\\d{4})|5(?:[0-4]\\d{2}|[5-9]\\d{6})|9\\d{6})","\\d{6,10}",null,null,"899123456"],[null,null,"84(?:[08]\\d{6}|[17]\\d{3})","\\d{6,9}",null,null,"848123456"],[null,null,"1(?:78\\d|99)\\d{6}","\\d{9,10}",null,null,"1781234567"],[null,null,"55\\d{8}","\\d{10}",null,null,"5512345678"],"IT",39,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[26]|55"],"","",0],[null,"(0[26])(\\d{4})(\\d{5})","$1 $2 $3",["0[26]"],"","",0],[null,"(0[26])(\\d{4,6})","$1 $2",["0[26]"],"","",0],[null,"(0\\d{2})(\\d{3,4})(\\d{4})","$1 $2 $3",["0[13-57-9][0159]"],"","",0],[null,"(\\d{3})(\\d{3,6})","$1 $2",["0[13-57-9][0159]|8(?:03|4[17]|9[245])","0[13-57-9][0159]|8(?:03|4[17]|9(?:2|[45][0-4]))"],"","",0],[null,"(0\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["0[13-57-9][2-46-8]"],"","",0],[null,"(0\\d{3})(\\d{2,6})","$1 $2",["0[13-57-9][2-46-8]"],"","",0],[null,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[13]|8(?:00|4[08]|9[59])","[13]|8(?:00|4[08]|9(?:5[5-9]|9))"],"","",0],[null,"(\\d{4})(\\d{4})","$1 $2",["894","894[5-9]"],"","",0],[null,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["3"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"848\\d{6}","\\d{9}",null,null,"848123456"],[null,null,"NA","NA"],1,[null,null,"11[2358]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"JE":[null,[null,null,"[135789]\\d{6,9}","\\d{6,10}"],[null,null,"1534\\d{6}","\\d{6,10}",null,null,"1534456789"],[null,null,"7(?:509|7(?:00|97)|829|937)\\d{6}","\\d{10}",null,null,"7797123456"],[null,null,"80(?:07(?:35|81)|8901)\\d{4}","\\d{10}",null,null,"8007354567"],[null,null,"(?:871206|90(?:066[59]|1810|71(?:07|55)))\\d{4}","\\d{10}",null,null,"9018105678"],[null,null,"8(?:4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|70002)\\d{4}","\\d{10}",null,null,"8447034567"],[null,null,"701511\\d{4}","\\d{10}",null,null,"7015115678"],[null,null,"56\\d{8}","\\d{10}",null,null,"5612345678"],"JE",44,"00","0"," x",null,"0",null,null,null,null,null,[null,null,"76(?:0[012]|2[356]|4[0134]|5[49]|6[0-369]|77|81|9[39])\\d{6}","\\d{10}",null,null,"7640123456"],null,null,[null,null,"NA","NA"],[null,null,"3(?:0(?:07(?:35|81)|8901)|3\\d{4}|4(?:4(?:4(?:05|42|69)|703)|5(?:041|800))|7(?:0002|1206))\\d{4}|55\\d{8}","\\d{10}",null,null,"5512345678"],null,[null,null,"112|999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"JM":[null,[null,null,"[589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"876(?:5(?:0[12]|1[0-468]|2[35]|63)|6(?:0[1-3579]|1[027-9]|[23]\\d|40|5[06]|6[2-589]|7[05]|8[04]|9[4-9])|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}","\\d{7}(?:\\d{3})?",null,null,"8765123456"],[null,null,"876(?:2[1789]\\d|[348]\\d{2}|5(?:08|27|6[0-24-9]|[3-578]\\d)|7(?:0[07]|7\\d|8[1-47-9]|9[0-36-9])|9(?:[01]9|9[0579]))\\d{4}","\\d{10}",null,null,"8762101234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"JM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"876",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[09]","\\d{3}",null,null,"119"],[null,null,"NA","NA"]],"JO":[null,[null,null,"[235-9]\\d{7,8}","\\d{7,9}"],[null,null,"(?:2(?:6(?:2[0-35-9]|3[0-57-8]|4[24-7]|5[0-24-8]|[6-9][02])|7(?:0[1-79]|10|2[014-7]|3[0-689]|4[019]|5[0-3578]))|32(?:0[1-69]|1[1-35-7]|2[024-7]|3\\d|[457][02]|60)|53(?:[013][02]|2[0-59]|49|5[0-35-9]|6[15]|7[45]|8[1-6]|9[0-36-9])|6(?:2[50]0|300|4(?:0[0125]|1[2-7]|2[0569]|[38][07-9]|4[025689]|6[0-589]|7\\d|9[0-2])|5(?:[01][056]|2[034]|3[0-57-9]|4[17-8]|5[0-69]|6[0-35-9]|7[1-379]|8[0-68]|9[02-39]))|87(?:[02]0|7[08]|9[09]))\\d{4}","\\d{7,8}",null,null,"62001234"],[null,null,"7(?:55|7[25-9]|8[5-9]|9[05-9])\\d{6}","\\d{9}",null,null,"790123456"],[null,null,"80\\d{6}","\\d{8}",null,null,"80012345"],[null,null,"900\\d{5}","\\d{8}",null,null,"90012345"],[null,null,"85\\d{6}","\\d{8}",null,null,"85012345"],[null,null,"70\\d{7}","\\d{9}",null,null,"700123456"],[null,null,"NA","NA"],"JO",962,"00","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[2356]|87"],"(0$1)","",0],[null,"(7)(\\d{4})(\\d{4})","$1 $2 $3",["7[457-9]"],"0$1","",0],[null,"(\\d{3})(\\d{5,6})","$1 $2",["70|8[0158]|9"],"0$1","",0]],null,[null,null,"74(?:66|77)\\d{5}","\\d{9}",null,null,"746612345"],null,null,[null,null,"NA","NA"],[null,null,"8(?:10|8\\d)\\d{5}","\\d{8}",null,null,"88101234"],null,[null,null,"1(?:12|91)|911","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"JP":[null,[null,null,"[1-9]\\d{8,9}|0(?:[36]\\d{7,14}|7\\d{5,7}|8\\d{7})","\\d{7,16}"],[null,null,"(?:1(?:1[235-8]|2[3-6]|3[3-9]|4[2-6]|[58][2-8]|6[2-7]|7[2-9]|9[1-9])|2[2-9]\\d|[36][1-9]\\d|4(?:6[02-8]|[2-578]\\d|9[2-59])|5(?:6[1-9]|7[2-8]|[2-589]\\d)|7(?:3[4-9]|4[02-9]|[25-9]\\d)|8(?:3[2-9]|4[5-9]|5[1-9]|8[03-9]|[2679]\\d)|9(?:[679][1-9]|[2-58]\\d))\\d{6}","\\d{9}",null,null,"312345678"],[null,null,"(?:[79]0\\d|80[1-9])\\d{7}","\\d{10}",null,null,"7012345678"],[null,null,"120\\d{6}|800\\d{7}|0(?:37\\d{6,13}|66\\d{6,13}|777(?:[01]\\d{2}|5\\d{3}|8\\d{4})|882[1245]\\d{4})","\\d{7,16}",null,null,"120123456"],[null,null,"990\\d{6}","\\d{9}",null,null,"990123456"],[null,null,"NA","NA"],[null,null,"60\\d{7}","\\d{9}",null,null,"601234567"],[null,null,"50[1-9]\\d{7}","\\d{10}",null,null,"5012345678"],"JP",81,"010","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{3})(\\d{3})","$1-$2-$3",["(?:12|57|99)0"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["800"],"0$1","",0],[null,"(\\d{3})(\\d{4})","$1-$2",["077"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{3,4})","$1-$2-$3",["077"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["088"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{3,4})","$1-$2-$3",["0(?:37|66)"],"0$1","",0],[null,"(\\d{3})(\\d{4})(\\d{4,5})","$1-$2-$3",["0(?:37|66)"],"0$1","",0],[null,"(\\d{3})(\\d{5})(\\d{5,6})","$1-$2-$3",["0(?:37|66)"],"0$1","",0],[null,"(\\d{3})(\\d{6})(\\d{6,7})","$1-$2-$3",["0(?:37|66)"],"0$1","",0],[null,"(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["[2579]0|80[1-9]"],"0$1","",0],[null,"(\\d{4})(\\d)(\\d{4})","$1-$2-$3",["1(?:26|3[79]|4[56]|5[4-68]|6[3-5])|5(?:76|97)|499|746|8(?:3[89]|63|47|51)|9(?:49|80|9[16])","1(?:267|3(?:7[247]|9[278])|4(?:5[67]|66)|5(?:47|58|64|8[67])|6(?:3[245]|48|5[4-68]))|5(?:76|97)9|499[2468]|7468|8(?:3(?:8[78]|96)|636|477|51[24])|9(?:496|802|9(?:1[23]|69))","1(?:267|3(?:7[247]|9[278])|4(?:5[67]|66)|5(?:47|58|64|8[67])|6(?:3[245]|48|5[4-68]))|5(?:769|979[2-69])|499[2468]|7468|8(?:3(?:8[78]|96[2457-9])|636[2-57-9]|477|51[24])|9(?:496|802|9(?:1[23]|69))"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["1(?:2[3-6]|3[3-9]|4[2-6]|5[2-8]|[68][2-7]|7[2-689]|9[1-578])|2(?:2[03-689]|3[3-58]|4[0-468]|5[04-8]|6[013-8]|7[06-9]|8[02-57-9]|9[13])|4(?:2[28]|3[689]|6[035-7]|7[05689]|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9[4-9])|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9[014-9])|8(?:2[49]|3[3-8]|4[5-8]|5[2-9]|6[35-9]|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9[3-7])","1(?:2[3-6]|3[3-9]|4[2-6]|5(?:[236-8]|[45][2-69])|[68][2-7]|7[2-689]|9[1-578])|2(?:2(?:[04-689]|3[23])|3[3-58]|4[0-468]|5(?:5[78]|7[2-4]|[0468][2-9])|6(?:[0135-8]|4[2-5])|7(?:[0679]|8[2-7])|8(?:[024578]|3[25-9]|9[6-9])|9(?:11|3[2-4]))|4(?:2(?:2[2-9]|8[237-9])|3[689]|6[035-7]|7(?:[059][2-8]|[68])|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9(?:[89][2-8]|[4-7]))|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9(?:[017-9]|4[6-8]|5[2-478]|6[2-589]))|8(?:2(?:4[4-8]|9[2-8])|3(?:7[2-6]|[3-6][2-9]|8[2-5])|4[5-8]|5[2-9]|6(?:[37]|5[4-7]|6[2-9]|8[2-8]|9[236-9])|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9(?:3[34]|[4-7]))","1(?:2[3-6]|3[3-9]|4[2-6]|5(?:[236-8]|[45][2-69])|[68][2-7]|7[2-689]|9[1-578])|2(?:2(?:[04-689]|3[23])|3[3-58]|4[0-468]|5(?:5[78]|7[2-4]|[0468][2-9])|6(?:[0135-8]|4[2-5])|7(?:[0679]|8[2-7])|8(?:[024578]|3[25-9]|9[6-9])|9(?:11|3[2-4]))|4(?:2(?:2[2-9]|8[237-9])|3[689]|6[035-7]|7(?:[059][2-8]|[68])|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9(?:[89][2-8]|[4-7]))|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9(?:[017-9]|4[6-8]|5[2-478]|6[2-589]))|8(?:2(?:4[4-8]|9(?:[3578]|20|4[04-9]|6[56]))|3(?:7(?:[2-5]|6[0-59])|[3-6][2-9]|8[2-5])|4[5-8]|5[2-9]|6(?:[37]|5(?:[467]|5[014-9])|6(?:[2-8]|9[02-69])|8[2-8]|9(?:[236-8]|9[23]))|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9(?:3(?:3[02-9]|4[0-24689])|4[2-69]|[5-7]))","1(?:2[3-6]|3[3-9]|4[2-6]|5(?:[236-8]|[45][2-69])|[68][2-7]|7[2-689]|9[1-578])|2(?:2(?:[04-689]|3[23])|3[3-58]|4[0-468]|5(?:5[78]|7[2-4]|[0468][2-9])|6(?:[0135-8]|4[2-5])|7(?:[0679]|8[2-7])|8(?:[024578]|3[25-9]|9[6-9])|9(?:11|3[2-4]))|4(?:2(?:2[2-9]|8[237-9])|3[689]|6[035-7]|7(?:[059][2-8]|[68])|80|9[3-5])|5(?:3[1-36-9]|4[4578]|5[013-8]|6[1-9]|7[2-8]|8[14-7]|9(?:[89][2-8]|[4-7]))|7(?:2[15]|3[5-9]|4[02-9]|6[135-8]|7[0-4689]|9(?:[017-9]|4[6-8]|5[2-478]|6[2-589]))|8(?:2(?:4[4-8]|9(?:[3578]|20|4[04-9]|6(?:5[25]|60)))|3(?:7(?:[2-5]|6[0-59])|[3-6][2-9]|8[2-5])|4[5-8]|5[2-9]|6(?:[37]|5(?:[467]|5[014-9])|6(?:[2-8]|9[02-69])|8[2-8]|9(?:[236-8]|9[23]))|7[579]|8[03-579]|9[2-8])|9(?:[23]0|4[02-46-9]|5[024-79]|6[4-9]|7[2-47-9]|8[02-7]|9(?:3(?:3[02-9]|4[0-24689])|4[2-69]|[5-7]))"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1|2(?:2[37]|5[5-9]|64|78|8[39]|91)|4(?:2[2689]|64|7[347])|5(?:[2-589]|39)|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93)","1|2(?:2[37]|5(?:[57]|[68]0|9[19])|64|78|8[39]|917)|4(?:2(?:[68]|20|9[178])|64|7[347])|5(?:[2-589]|39[67])|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93[34])","1|2(?:2[37]|5(?:[57]|[68]0|9(?:17|99))|64|78|8[39]|917)|4(?:2(?:[68]|20|9[178])|64|7[347])|5(?:[2-589]|39[67])|60|8(?:[46-9]|3[279]|2[124589])|9(?:[235-8]|93(?:31|4))"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["2(?:9[14-79]|74|[34]7|[56]9)|82|993"],"0$1","",0],[null,"(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["3|4(?:2[09]|7[01])|6[1-9]"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["[2479][1-9]"],"0$1","",0]],null,[null,null,"20\\d{8}","\\d{10}",null,null,"2012345678"],null,null,[null,null,"0(?:37\\d{6,13}|66\\d{6,13}|777(?:[01]\\d{2}|5\\d{3}|8\\d{4})|882[1245]\\d{4})","\\d{7,16}",null,null,"0777012"],[null,null,"570\\d{6}","\\d{9}",null,null,"570123456"],1,[null,null,"11[09]","\\d{3}",null,null,"110"],[null,null,"NA","NA"]],"KE":[null,[null,null,"20\\d{6,7}|[4-9]\\d{6,9}","\\d{5,10}"],[null,null,"20\\d{6,7}|4(?:[013]\\d{7}|[24-6]\\d{5,7})|5(?:[0-36-8]\\d{5,7}|[459]\\d{5})|6(?:[08]\\d{5}|[14-79]\\d{5,7}|2\\d{7})","\\d{5,9}",null,null,"202012345"],[null,null,"7(?:0[0-8]|[123]\\d|5[0-6]|7[0-5]|8[5-9])\\d{6}","\\d{9}",null,null,"712123456"],[null,null,"800[24-8]\\d{5,6}","\\d{9,10}",null,null,"800223456"],[null,null,"900[02-578]\\d{5}","\\d{9}",null,null,"900223456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"KE",254,"000","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{4,7})","$1 $2",["[24-6]"],"0$1","",0],[null,"(\\d{3})(\\d{6,7})","$1 $2",["7"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"KG":[null,[null,null,"[35-8]\\d{8,9}","\\d{5,10}"],[null,null,"(?:3(?:1(?:2\\d|3[1-9]|47|5[02]|6[1-8])|2(?:22|3[0-479]|6[0-7])|4(?:22|5[6-9]|6[0-4])|5(?:22|3[4-7]|59|6[0-5])|6(?:22|5[35-7]|6[0-3])|7(?:22|3[468]|4[1-9]|59|6\\d|7[5-7])|9(?:22|4[1-8]|6[0-8]))|6(?:09|12|2[2-4])\\d)\\d{5}","\\d{5,10}",null,null,"312123456"],[null,null,"5[124-7]\\d{7}|7(?:0[0-357-9]|7\\d)\\d{6}","\\d{9}",null,null,"700123456"],[null,null,"800\\d{6,7}","\\d{9,10}",null,null,"800123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"KG",996,"00","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["31[25]|[5-7]"],"0$1","",0],[null,"(\\d{4})(\\d{5})","$1 $2",["3(?:1[36]|[2-9])"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d)(\\d{3})","$1 $2 $3 $4",["8"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"10[123]","\\d{3}",null,null,"101"],[null,null,"NA","NA"]],"KH":[null,[null,null,"[1-9]\\d{7,9}","\\d{6,10}"],[null,null,"(?:2[3-6]|3[2-6]|4[2-4]|[5-7][2-5])(?:[237-9]|4[56]|5\\d|6\\d?)\\d{5}|238\\d{6}","\\d{6,9}",null,null,"23756789"],[null,null,"(?:1(?:[013-9]|2\\d?)|31\\d|6[016-9]|7(?:[07-9]|6\\d)|8(?:[013-79]|8\\d)|9(?:6\\d|7\\d?|[0-589]))\\d{6}","\\d{8,9}",null,null,"91234567"],[null,null,"1800(?:1\\d|2[019])\\d{4}","\\d{10}",null,null,"1800123456"],[null,null,"1900(?:1\\d|2[09])\\d{4}","\\d{10}",null,null,"1900123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"KH",855,"00[14-9]","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["1\\d[1-9]|[2-9]"],"0$1","",0],[null,"(1[89]00)(\\d{3})(\\d{3})","$1 $2 $3",["1[89]0"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[789]|666","\\d{3}",null,null,"117"],[null,null,"NA","NA"]],"KI":[null,[null,null,"[2-689]\\d{4}","\\d{5}"],[null,null,"(?:[234]\\d|50|8[1-5])\\d{3}","\\d{5}",null,null,"31234"],[null,null,"6\\d{4}|9(?:[0-8]\\d|9[015-8])\\d{2}","\\d{5}",null,null,"61234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"KI",686,"00",null,null,null,"0",null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"99[2349]","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"KM":[null,[null,null,"[379]\\d{6}","\\d{7}"],[null,null,"7(?:6[0-37-9]|7[0-57-9])\\d{4}","\\d{7}",null,null,"7712345"],[null,null,"3[234]\\d{5}","\\d{7}",null,null,"3212345"],[null,null,"NA","NA"],[null,null,"(?:39[01]|9[01]0)\\d{4}","\\d{7}",null,null,"9001234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"KM",269,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[78]","\\d{2}",null,null,"17"],[null,null,"NA","NA"]],"KN":[null,[null,null,"[589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"869(?:2(?:29|36)|302|4(?:6[5-9]|70))\\d{4}","\\d{7}(?:\\d{3})?",null,null,"8692361234"],[null,null,"869(?:5(?:5[6-8]|6[5-7])|66\\d|76[02-6])\\d{4}","\\d{10}",null,null,"8695561234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"KN",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"869",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"333|9(?:11|99)","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"KP":[null,[null,null,"1\\d{9}|[28]\\d{7}","\\d{6,8}|\\d{10}"],[null,null,"2\\d{7}|85\\d{6}","\\d{6,8}",null,null,"21234567"],[null,null,"19[123]\\d{7}","\\d{10}",null,null,"1921234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"KP",850,"00|99","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["1"],"0$1","",0],[null,"(\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"2(?:[0-24-9]\\d{2}|3(?:[0-79]\\d|8[02-9]))\\d{4}","\\d{8}",null,null,"23821234"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"KR":[null,[null,null,"[1-7]\\d{3,9}|8\\d{8}","\\d{4,10}"],[null,null,"(?:2|3[1-3]|[46][1-4]|5[1-5])(?:1\\d{2,3}|[1-9]\\d{6,7})","\\d{4,10}",null,null,"22123456"],[null,null,"1[0-26-9]\\d{7,8}","\\d{9,10}",null,null,"1023456789"],[null,null,"80\\d{7}","\\d{9}",null,null,"801234567"],[null,null,"60[2-9]\\d{6}","\\d{9}",null,null,"602345678"],[null,null,"NA","NA"],[null,null,"50\\d{8}","\\d{10}",null,null,"5012345678"],[null,null,"70\\d{8}","\\d{10}",null,null,"7012345678"],"KR",82,"00(?:[124-68]|[37]\\d{2})","0",null,null,"0(8[1-46-8]|85\\d{2})?",null,null,null,[[null,"(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["1(?:0|1[19]|[69]9|5[458])|[57]0","1(?:0|1[19]|[69]9|5(?:44|59|8))|[57]0"],"0$1","0$CC-$1",0],[null,"(\\d{2})(\\d{3,4})(\\d{4})","$1-$2-$3",["1(?:[169][2-8]|[78]|5[1-4])|[68]0|[3-6][1-9][1-9]","1(?:[169][2-8]|[78]|5(?:[1-3]|4[56]))|[68]0|[3-6][1-9][1-9]"],"0$1","0$CC-$1",0],[null,"(\\d{3})(\\d)(\\d{4})","$1-$2-$3",["131","1312"],"0$1","0$CC-$1",0],[null,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["131","131[13-9]"],"0$1","0$CC-$1",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["13[2-9]"],"0$1","0$CC-$1",0],[null,"(\\d{2})(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3-$4",["30"],"0$1","0$CC-$1",0],[null,"(\\d)(\\d{3,4})(\\d{4})","$1-$2-$3",["2[1-9]"],"0$1","0$CC-$1",0],[null,"(\\d)(\\d{3,4})","$1-$2",["21[0-46-9]"],"0$1","0$CC-$1",0],[null,"(\\d{2})(\\d{3,4})","$1-$2",["[3-6][1-9]1","[3-6][1-9]1(?:[0-46-9])"],"0$1","0$CC-$1",0],[null,"(\\d{4})(\\d{4})","$1-$2",["1(?:5[46-9]|6[04678])","1(?:5(?:44|66|77|88|99)|6(?:00|44|6[16]|70|88))"],"$1","0$CC-$1",0]],null,[null,null,"15\\d{7,8}","\\d{9,10}",null,null,"1523456789"],null,null,[null,null,"NA","NA"],[null,null,"1(?:5(?:44|66|77|88|99)|6(?:00|44|6[16]|70|88))\\d{4}","\\d{8}",null,null,"15441234"],null,[null,null,"11[29]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"KW":[null,[null,null,"[12569]\\d{6,7}","\\d{7,8}"],[null,null,"(?:18\\d|2(?:[23]\\d{2}|4(?:[1-35-9]\\d|44)|5(?:0[034]|[2-46]\\d|5[1-3]|7[1-7])))\\d{4}","\\d{7,8}",null,null,"22345678"],[null,null,"(?:5(?:1[0-35]|[05]\\d)|6(?:0[034679]|5[015-9]|6\\d|7[067]|9[0369])|9(?:0[09]|4[049]|6[069]|[79]\\d|88))\\d{5}","\\d{8}",null,null,"50012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"KW",965,"00",null,null,null,null,null,null,null,[[null,"(\\d{4})(\\d{3,4})","$1 $2",["[1269]"],"","",0],[null,"(5[015]\\d)(\\d{5})","$1 $2",["5"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"KY":[null,[null,null,"[3589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"345(?:2(?:22|44)|444|6(?:23|38|40)|7(?:4[35-79]|6[6-9]|77)|8(?:00|1[45]|25|[48]8)|9(?:14|4[035-9]))\\d{4}","\\d{7}(?:\\d{3})?",null,null,"3452221234"],[null,null,"345(?:32[1-9]|5(?:1[67]|2[5-7]|4[6-8]|76)|9(?:1[67]|2[3-9]|3[689]))\\d{4}","\\d{10}",null,null,"3453231234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002345678"],[null,null,"900[2-9]\\d{6}|345976\\d{4}","\\d{10}",null,null,"9002345678"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"KY",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"345849\\d{4}","\\d{10}",null,null,"3458491234"],null,"345",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"KZ":[null,[null,null,"(?:33\\d|7\\d{2}|80[09])\\d{7}","\\d{10}"],[null,null,"33622\\d{5}|7(?:1(?:0(?:[23]\\d|4[023]|59|63)|1(?:[23]\\d|4[0-79]|59)|2(?:[23]\\d|59)|3(?:2\\d|3[1-79]|4[0-35-9]|59)|4(?:2\\d|3[013-79]|4[0-8]|5[1-79])|5(?:2\\d|3[1-8]|4[1-7]|59)|6(?:[234]\\d|5[19]|61)|72\\d|8(?:[27]\\d|3[1-46-9]|4[0-5]))|2(?:1(?:[23]\\d|4[46-9]|5[3469])|2(?:2\\d|3[0679]|46|5[12679])|3(?:[234]\\d|5[139])|4(?:2\\d|3[1235-9]|59)|5(?:[23]\\d|4[01246-8]|59|61)|6(?:2\\d|3[1-9]|4[0-4]|59)|7(?:[237]\\d|40|5[279])|8(?:[23]\\d|4[0-3]|59)|9(?:2\\d|3[124578]|59)))\\d{5}","\\d{10}",null,null,"7123456789"],[null,null,"7(?:0[01257]|47|6[02-4]|7[15-8]|85)\\d{7}","\\d{10}",null,null,"7710009998"],[null,null,"800\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"809\\d{7}","\\d{10}",null,null,"8091234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"751\\d{7}","\\d{10}",null,null,"7511234567"],"KZ",7,"810","8",null,null,"8",null,"8~10",null,null,null,[null,null,"NA","NA"],null,null,[null,null,"751\\d{7}","\\d{10}",null,null,"7511234567"],[null,null,"NA","NA"],null,[null,null,"1(?:0[123]|12)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"LA":[null,[null,null,"[2-8]\\d{7,9}","\\d{6,10}"],[null,null,"(?:2[13]|[35-7][14]|41|8[1468])\\d{6}","\\d{6,8}",null,null,"21212862"],[null,null,"20(?:2[2389]|5[4-689]|7[6-8]|9[57-9])\\d{6}","\\d{10}",null,null,"2023123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"LA",856,"00","0",null,null,"0",null,null,null,[[null,"(20)(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3 $4",["20"],"0$1","",0],[null,"([2-8]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["2[13]|[3-8]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"19[015]","\\d{3}",null,null,"190"],[null,null,"NA","NA"]],"LB":[null,[null,null,"[13-9]\\d{6,7}","\\d{7,8}"],[null,null,"(?:[14-6]\\d{2}|7(?:[2-579]\\d|62|8[0-7])|[89][2-9]\\d)\\d{4}","\\d{7}",null,null,"1123456"],[null,null,"(?:3\\d|7(?:[01]\\d|6[013-9]|8[89]|91))\\d{5}","\\d{7,8}",null,null,"71123456"],[null,null,"NA","NA"],[null,null,"9[01]\\d{6}","\\d{8}",null,null,"90123456"],[null,null,"8[01]\\d{6}","\\d{8}",null,null,"80123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],"LB",961,"00","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[13-6]|7(?:[2-579]|62|8[0-7])|[89][2-9]"],"0$1","",0],[null,"([7-9]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[89][01]|7(?:[01]|6[013-9]|8[89]|91)"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:12|40|75)|999","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"LC":[null,[null,null,"[5789]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"758(?:234|4(?:30|5[0-9]|6[2-9]|8[0-2])|572|638|758)\\d{4}","\\d{7}(?:\\d{3})?",null,null,"7582345678"],[null,null,"758(?:28[4-7]|384|4(?:6[01]|8[4-9])|5(?:1[89]|20|84)|7(?:1[2-9]|2[0-6]))\\d{4}","\\d{10}",null,null,"7582845678"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"LC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"758",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"9(?:11|99)","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"LI":[null,[null,null,"6\\d{8}|[23789]\\d{6}","\\d{7,9}"],[null,null,"(?:2(?:01|1[27]|3\\d|6[02-578]|96)|3(?:7[0135-7]|8[048]|9[0269]))\\d{4}","\\d{7}",null,null,"2345678"],[null,null,"6(?:51[01]|6(?:[01][0-4]|2[016-9]|88)|710)\\d{5}|7(?:36|4[25]|56|[7-9]\\d)\\d{4}","\\d{7,9}",null,null,"661234567"],[null,null,"80(?:0(?:2[238]|79)|9\\d{2})\\d{2}","\\d{7}",null,null,"8002222"],[null,null,"90(?:0(?:2[278]|79)|1(?:23|3[012])|6(?:4\\d|6[0126]))\\d{2}","\\d{7}",null,null,"9002222"],[null,null,"NA","NA"],[null,null,"701\\d{4}","\\d{7}",null,null,"7011234"],[null,null,"NA","NA"],"LI",423,"00","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3",["[23]|7[3-57-9]|87"],"","",0],[null,"(6\\d)(\\d{3})(\\d{3})","$1 $2 $3",["6"],"","",0],[null,"(6[567]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["6[567]"],"","",0],[null,"(69)(7\\d{2})(\\d{4})","$1 $2 $3",["697"],"","",0],[null,"([7-9]0\\d)(\\d{2})(\\d{2})","$1 $2 $3",["[7-9]0"],"","",0],[null,"([89]0\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]0"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"87(?:0[128]|7[0-4])\\d{3}","\\d{7}",null,null,"8770123"],null,[null,null,"1(?:1[278]|44)","\\d{3}",null,null,"112"],[null,null,"697(?:[35]6|4[25]|[7-9]\\d)\\d{4}","\\d{9}",null,null,"697361234"]],"LK":[null,[null,null,"[1-9]\\d{8}","\\d{7,9}"],[null,null,"(?:[189]1|2[13-7]|3[1-8]|4[157]|5[12457]|6[35-7])[2-57]\\d{6}","\\d{7,9}",null,null,"112345678"],[null,null,"7[125-8]\\d{7}","\\d{9}",null,null,"712345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"LK",94,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{1})(\\d{6})","$1 $2 $3",["[1-689]"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[0189]","\\d{3}",null,null,"119"],[null,null,"NA","NA"]],"LR":[null,[null,null,"(?:[29]\\d|[4-6]|7\\d{1,2}|[38]\\d{2})\\d{6}","\\d{7,9}"],[null,null,"2\\d{7}","\\d{8}",null,null,"21234567"],[null,null,"(?:4[67]|5\\d|6[4-8]|77?\\d{2}|88\\d{2})\\d{5}","\\d{7,9}",null,null,"4612345"],[null,null,"NA","NA"],[null,null,"90\\d{6}","\\d{8}",null,null,"90123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"33200\\d{4}","\\d{9}",null,null,"332001234"],"LR",231,"00","0",null,null,"0",null,null,null,[[null,"([279]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[279]"],"0$1","",0],[null,"(7\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["7"],"0$1","",0],[null,"([4-6])(\\d{3})(\\d{3})","$1 $2 $3",["[4-6]"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[38]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"355|911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"LS":[null,[null,null,"[2568]\\d{7}","\\d{8}"],[null,null,"2\\d{7}","\\d{8}",null,null,"22123456"],[null,null,"[56]\\d{7}","\\d{8}",null,null,"50123456"],[null,null,"800[256]\\d{4}","\\d{8}",null,null,"80021234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"LS",266,"00",null,null,null,null,null,null,null,[[null,"(\\d{4})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[257]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"LT":[null,[null,null,"[3-9]\\d{7}","\\d{8}"],[null,null,"(?:3[1478]|4[124-6]|52)\\d{6}","\\d{8}",null,null,"31234567"],[null,null,"6\\d{7}","\\d{8}",null,null,"61234567"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"9(?:0[0239]|10)\\d{5}","\\d{8}",null,null,"90012345"],[null,null,"808\\d{5}","\\d{8}",null,null,"80812345"],[null,null,"700\\d{5}","\\d{8}",null,null,"70012345"],[null,null,"NA","NA"],"LT",370,"00","8",null,null,"[08]",null,null,null,[[null,"([34]\\d)(\\d{6})","$1 $2",["37|4(?:1|5[45]|6[2-4])"],"(8-$1)","",1],[null,"([3-6]\\d{2})(\\d{5})","$1 $2",["3[148]|4(?:[24]|6[09])|528|6"],"(8-$1)","",1],[null,"([7-9]\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["[7-9]"],"8 $1","",0],[null,"(5)(2\\d{2})(\\d{4})","$1 $2 $3",["52[0-79]"],"(8-$1)","",1]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"70[67]\\d{5}","\\d{8}",null,null,"70712345"],null,[null,null,"0(?:11?|22?|33?)|1(?:0[123]|12)","\\d{2,3}",null,null,"112"],[null,null,"NA","NA"]],"LU":[null,[null,null,"[24-9]\\d{3,10}|3(?:[0-46-9]\\d{2,9}|5[013-9]\\d{1,8})","\\d{4,11}"],[null,null,"(?:2(?:2\\d{1,2}|3[2-9]|[67]\\d|4[1-8]\\d?|5[1-5]\\d?|9[0-24-9]\\d?)|3(?:[059][05-9]|[13]\\d|[26][015-9]|4[0-26-9]|7[0-389]|8[08])\\d?|4\\d{2,3}|5(?:[01458]\\d|[27][0-69]|3[0-3]|[69][0-7])\\d?|7(?:1[019]|2[05-9]|3[05]|[45][07-9]|[679][089]|8[06-9])\\d?|8(?:0[2-9]|1[0-36-9]|3[3-9]|[469]9|[58][7-9]|7[89])\\d?|9(?:0[89]|2[0-49]|37|49|5[0-27-9]|7[7-9]|9[0-478])\\d?)\\d{1,7}","\\d{4,11}",null,null,"27123456"],[null,null,"6[269][18]\\d{6}","\\d{9}",null,null,"628123456"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"90[01]\\d{5}","\\d{8}",null,null,"90012345"],[null,null,"801\\d{5}","\\d{8}",null,null,"80112345"],[null,null,"70\\d{6}","\\d{8}",null,null,"70123456"],[null,null,"20(?:1\\d{5}|[2-689]\\d{1,7})","\\d{4,10}",null,null,"20201234"],"LU",352,"00",null,null,null,"(15(?:0[06]|1[12]|35|4[04]|55|6[26]|77|88|99)\\d)",null,null,null,[[null,"(\\d{2})(\\d{3})","$1 $2",["[2-5]|7[1-9]|[89](?:[1-9]|0[2-9])"],"","$CC $1",0],[null,"(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",["[2-5]|7[1-9]|[89](?:[1-9]|0[2-9])"],"","$CC $1",0],[null,"(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["20"],"","$CC $1",0],[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4",["2(?:[0367]|4[3-8])"],"","$CC $1",0],[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["20"],"","$CC $1",0],[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{1,2})","$1 $2 $3 $4 $5",["2(?:[0367]|4[3-8])"],"","$CC $1",0],[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{1,4})","$1 $2 $3 $4",["2(?:[12589]|4[12])|[3-5]|7[1-9]|[89](?:[1-9]|0[2-9])"],"","$CC $1",0],[null,"(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["[89]0[01]|70"],"","$CC $1",0],[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["6"],"","$CC $1",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[23]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"LV":[null,[null,null,"[2689]\\d{7}","\\d{8}"],[null,null,"6[3-8]\\d{6}","\\d{8}",null,null,"63123456"],[null,null,"2\\d{7}","\\d{8}",null,null,"21234567"],[null,null,"80\\d{6}","\\d{8}",null,null,"80123456"],[null,null,"90\\d{6}","\\d{8}",null,null,"90123456"],[null,null,"81\\d{6}","\\d{8}",null,null,"81123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],"LV",371,"00",null,null,null,null,null,null,null,[[null,"([2689]\\d)(\\d{3})(\\d{3})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"0[123]|112","\\d{2,3}",null,null,"112"],[null,null,"NA","NA"]],"LY":[null,[null,null,"[25679]\\d{8}","\\d{7,9}"],[null,null,"(?:2[1345]|5[1347]|6[123479]|71)\\d{7}","\\d{7,9}",null,null,"212345678"],[null,null,"9[1-6]\\d{7}","\\d{9}",null,null,"912345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"LY",218,"00","0",null,null,"0",null,null,null,[[null,"([25679]\\d)(\\d{7})","$1-$2",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"19[013]","\\d{3}",null,null,"193"],[null,null,"NA","NA"]],"MA":[null,[null,null,"[5689]\\d{8}","\\d{9}"],[null,null,"5(?:2(?:(?:[015-7]\\d|2[2-9]|3[2-57]|4[2-8]|8[235-7])\\d|9(?:0\\d|[89]0))|3(?:(?:[0-4]\\d|[57][2-9]|6[235-8]|9[3-9])\\d|8(?:0\\d|[89]0)))\\d{4}","\\d{9}",null,null,"520123456"],[null,null,"6(?:0[0-8]|[124-7]\\d|3[013-8]|8[01]|99)\\d{6}","\\d{9}",null,null,"650123456"],[null,null,"80\\d{7}","\\d{9}",null,null,"801234567"],[null,null,"89\\d{7}","\\d{9}",null,null,"891234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MA",212,"00","0",null,null,"0",null,null,null,[[null,"([56]\\d{2})(\\d{6})","$1-$2",["5(?:2[015-7]|3[0-4])|6"],"0$1","",0],[null,"([58]\\d{3})(\\d{5})","$1-$2",["5(?:2[2-489]|3[5-9])|892","5(?:2(?:[2-48]|90)|3(?:[5-79]|80))|892"],"0$1","",0],[null,"(5\\d{4})(\\d{4})","$1-$2",["5(?:29|38)","5(?:29|38)[89]"],"0$1","",0],[null,"(8[09])(\\d{7})","$1-$2",["8(?:0|9[013-9])"],"0$1","",0]],null,[null,null,"NA","NA"],1,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:[59]|77)","\\d{2,3}",null,null,"15"],[null,null,"NA","NA"]],"MC":[null,[null,null,"[4689]\\d{7,8}","\\d{8,9}"],[null,null,"9[2-47-9]\\d{6}","\\d{8}",null,null,"99123456"],[null,null,"6\\d{8}|4\\d{7}","\\d{8,9}",null,null,"612345678"],[null,null,"(?:8\\d|90)\\d{6}","\\d{8}",null,null,"90123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MC",377,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[89]"],"$1","",0],[null,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["4"],"0$1","",0],[null,"(6)(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4 $5",["6"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"8\\d{7}","\\d{8}"],[null,null,"NA","NA"],null,[null,null,"1(?:12|[578])","\\d{2,3}",null,null,"112"],[null,null,"NA","NA"]],"MD":[null,[null,null,"[235-9]\\d{7}","\\d{8}"],[null,null,"(?:2(?:1[0569]|2\\d|3[015-7]|4[1-46-9]|5[0-24689]|6[2-589]|7[1-37]|9[1347-9])|5(?:33|5[257]))\\d{5}","\\d{8}",null,null,"22212345"],[null,null,"(?:562|6(?:50|7[1-6]|[089]\\d)|7(?:67|7[47-9]|[89]\\d))\\d{5}","\\d{8}",null,null,"65012345"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"90[056]\\d{5}","\\d{8}",null,null,"90012345"],[null,null,"808\\d{5}","\\d{8}",null,null,"80812345"],[null,null,"NA","NA"],[null,null,"3[08]\\d{6}","\\d{8}",null,null,"30123456"],"MD",373,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["22|3"],"0$1","",0],[null,"([25-7]\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["2[13-79]|[5-7]"],"0$1","",0],[null,"([89]\\d{2})(\\d{5})","$1 $2",["[89]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"8(?:03|14)\\d{5}","\\d{8}",null,null,"80312345"],null,[null,null,"112|90[123]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"ME":[null,[null,null,"[2-9]\\d{7,8}","\\d{6,9}"],[null,null,"(?:20[2-8]|3(?:0[2-7]|1[35-7]|2[3567]|3[4-7])|4(?:0[237]|1[27])|5(?:0[47]|1[27]|2[378]))\\d{5}","\\d{6,8}",null,null,"30234567"],[null,null,"6(?:32\\d|[89]\\d{2}|7(?:[0-8]\\d|9(?:[3-9]|[0-2]\\d)))\\d{4}","\\d{8,9}",null,null,"67622901"],[null,null,"800[28]\\d{4}","\\d{8}",null,null,"80080002"],[null,null,"(?:88\\d|9(?:4[13-8]|5[16-8]))\\d{5}","\\d{8}",null,null,"94515151"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"78[1-9]\\d{5}","\\d{8}",null,null,"78108780"],"ME",382,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[2-57-9]|6[3789]","[2-57-9]|6(?:[389]|7(?:[0-8]|9[3-9]))"],"0$1","",0],[null,"(67)(9)(\\d{3})(\\d{3})","$1 $2 $3 $4",["679","679[0-2]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"77\\d{6}","\\d{8}",null,null,"77273012"],null,[null,null,"1(?:12|2[234])","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"MG":[null,[null,null,"[23]\\d{8}","\\d{7,9}"],[null,null,"20(?:2\\d{2}|4[47]\\d|5[3467]\\d|6[279]\\d|7(?:2[29]|[35]\\d)|8[268]\\d|9[245]\\d)\\d{4}","\\d{7,9}",null,null,"202123456"],[null,null,"3(?:[02-4]\\d|90)\\d{6}","\\d{9}",null,null,"301234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"22\\d{7}","\\d{9}",null,null,"221234567"],"MG",261,"00","0",null,null,"0",null,null,null,[[null,"([23]\\d)(\\d{2})(\\d{3})(\\d{2})","$1 $2 $3 $4",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11?[78]","\\d{2,3}",null,null,"117"],[null,null,"NA","NA"]],"MF":[null,[null,null,"[56]\\d{8}","\\d{9}"],[null,null,"590(?:[02][79]|13|5[0-268]|[78]7)\\d{4}","\\d{9}",null,null,"590271234"],[null,null,"690(?:0[0-7]|[1-9]\\d)\\d{4}","\\d{9}",null,null,"690301234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MF",590,"00","0",null,null,"0",null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[578]","\\d{2}",null,null,"18"],[null,null,"NA","NA"]],"MH":[null,[null,null,"[2-6]\\d{6}","\\d{7}"],[null,null,"(?:247|528|625)\\d{4}","\\d{7}",null,null,"2471234"],[null,null,"(?:235|329|45[56]|545)\\d{4}","\\d{7}",null,null,"2351234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"635\\d{4}","\\d{7}",null,null,"6351234"],"MH",692,"011","1",null,null,"1",null,null,null,[[null,"(\\d{3})(\\d{4})","$1-$2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"MK":[null,[null,null,"[2-578]\\d{7}","\\d{8}"],[null,null,"(?:2(?:[23]\\d|5[124578]|6[01])|3(?:1[3-6]|[23][2-6]|4[2356])|4(?:[23][2-6]|4[3-6]|5[256]|6[25-8]|7[24-6]|8[4-6]))\\d{5}","\\d{6,8}",null,null,"22212345"],[null,null,"7(?:[0-25-8]\\d|33)\\d{5}","\\d{8}",null,null,"72345678"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"5[02-9]\\d{6}","\\d{8}",null,null,"50012345"],[null,null,"8(?:0[1-9]|[1-9]\\d)\\d{5}","\\d{8}",null,null,"80123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MK",389,"00","0",null,null,"0",null,null,null,[[null,"(2)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1","",0],[null,"([347]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[347]"],"0$1","",0],[null,"([58]\\d{2})(\\d)(\\d{2})(\\d{2})","$1 $2 $3 $4",["[58]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:12|9[234])","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"ML":[null,[null,null,"[246-8]\\d{7}","\\d{8}"],[null,null,"(?:2(?:0(?:2[0-589]|7[027-9])|1(?:2[5-7]|[3-689]\\d))|44[239]\\d)\\d{4}","\\d{8}",null,null,"20212345"],[null,null,"[67]\\d{7}","\\d{8}",null,null,"65012345"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"ML",223,"00",null,null,null,null,null,null,null,[[null,"([246-8]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[578]","\\d{2}",null,null,"17"],[null,null,"NA","NA"]],"MM":[null,[null,null,"[14578]\\d{5,7}|[26]\\d{5,8}|9(?:[258]|3\\d|4\\d{1,2}|[679]\\d?)\\d{6}","\\d{5,10}"],[null,null,"1(?:2\\d{1,2}|[3-5]\\d|6\\d?|[89][0-6]\\d)\\d{4}|2(?:[236-9]\\d{4}|4(?:0\\d{5}|\\d{4})|5(?:1\\d{3,6}|[02-9]\\d{3,5}))|4(?:2[245-8]|[346][2-6]|5[3-5])\\d{4}|5(?:2(?:20?|[3-8])|3[2-68]|4(?:21?|[4-8])|5[23]|6[2-4]|7[2-8]|8[24-7]|9[2-7])\\d{4}|6(?:0[23]|1[2356]|[24][2-6]|3[24-6]|5[2-4]|6[2-8]|7(?:[2367]|4\\d|5\\d?|8[145]\\d)|8[245]|9[24])\\d{4}|7(?:[04][24-8]|[15][2-7]|22|3[2-4])\\d{4}|8(?:1(?:2\\d?|[3-689])|2[2-8]|3[24]|4[24-7]|5[245]|6[23])\\d{4}","\\d{5,9}",null,null,"1234567"],[null,null,"17[01]\\d{4}|9(?:2[0-4]|3[136]\\d|4(?:0[0-4]\\d|[1379]\\d|[24][0-589]\\d|5\\d{2}|88)|5[0-6]|61?\\d|73\\d|8\\d|9(?:1\\d|[089]))\\d{5}","\\d{7,10}",null,null,"92123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"1333\\d{4}","\\d{8}",null,null,"13331234"],"MM",95,"00","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["1|2[45]"],"0$1","",0],[null,"(2)(\\d{4})(\\d{4})","$1 $2 $3",["251"],"0$1","",0],[null,"(\\d)(\\d{2})(\\d{3})","$1 $2 $3",["16|2"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["67|81"],"0$1","",0],[null,"(\\d{2})(\\d{2})(\\d{3,4})","$1 $2 $3",["[4-8]"],"0$1","",0],[null,"(9)(\\d{3})(\\d{4,5})","$1 $2 $3",["9(?:[235-9]|4[13789])"],"0$1","",0],[null,"(9)(4\\d{4})(\\d{4})","$1 $2 $3",["94[0245]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"199","\\d{3}",null,null,"199"],[null,null,"NA","NA"]],"MN":[null,[null,null,"[12]\\d{7,9}|[57-9]\\d{7}","\\d{6,10}"],[null,null,"[12](?:1\\d|2(?:[1-3]\\d?|7\\d)|3[2-8]\\d{1,2}|4[2-68]\\d{1,2}|5[1-4689]\\d{1,2})\\d{5}|5[0568]\\d{6}","\\d{6,10}",null,null,"50123456"],[null,null,"(?:8[89]|9[013-9])\\d{6}","\\d{8}",null,null,"88123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"7[05-8]\\d{6}","\\d{8}",null,null,"75123456"],"MN",976,"001","0",null,null,"0",null,null,null,[[null,"([12]\\d)(\\d{2})(\\d{4})","$1 $2 $3",["[12]1"],"0$1","",0],[null,"([12]2\\d)(\\d{5,6})","$1 $2",["[12]2[1-3]"],"0$1","",0],[null,"([12]\\d{3})(\\d{5})","$1 $2",["[12](?:27|[3-5])","[12](?:27|[3-5]\\d)2"],"0$1","",0],[null,"(\\d{4})(\\d{4})","$1 $2",["[57-9]"],"$1","",0],[null,"([12]\\d{4})(\\d{4,5})","$1 $2",["[12](?:27|[3-5])","[12](?:27|[3-5]\\d)[4-9]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"10[0-3]","\\d{3}",null,null,"102"],[null,null,"NA","NA"]],"MO":[null,[null,null,"[268]\\d{7}","\\d{8}"],[null,null,"(?:28[2-57-9]|8[2-57-9]\\d)\\d{5}","\\d{8}",null,null,"28212345"],[null,null,"6[236]\\d{6}","\\d{8}",null,null,"66123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MO",853,"00",null,null,null,null,null,null,null,[[null,"([268]\\d{3})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"MP":[null,[null,null,"[5689]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1238]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[589]|8[3-9]8|989)\\d{4}","\\d{7}(?:\\d{3})?",null,null,"6702345678"],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1238]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[589]|8[3-9]8|989)\\d{4}","\\d{7}(?:\\d{3})?",null,null,"6702345678"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"MP",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,"NA","NA"],null,"670",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"MQ":[null,[null,null,"[56]\\d{8}","\\d{9}"],[null,null,"596(?:0[2-5]|[12]0|3[05-9]|4[024-8]|[5-7]\\d|89|9[4-8])\\d{4}","\\d{9}",null,null,"596301234"],[null,null,"696(?:[0-479]\\d|5[01]|8[0-689])\\d{4}","\\d{9}",null,null,"696201234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MQ",596,"00","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:12|[578])","\\d{2,3}",null,null,"15"],[null,null,"NA","NA"]],"MR":[null,[null,null,"[2-48]\\d{7}","\\d{8}"],[null,null,"25[08]\\d{5}|35\\d{6}|45[1-7]\\d{5}","\\d{8}",null,null,"35123456"],[null,null,"(?:2(?:2\\d|70)|3(?:3\\d|6[1-36]|7[1-3])|4(?:4\\d|6[0457-9]|7[4-9]))\\d{5}","\\d{8}",null,null,"22123456"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MR",222,"00",null,null,null,null,null,null,null,[[null,"([2-48]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[78]","\\d{2}",null,null,"17"],[null,null,"NA","NA"]],"MS":[null,[null,null,"[5689]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"664491\\d{4}","\\d{7}(?:\\d{3})?",null,null,"6644912345"],[null,null,"66449[2-6]\\d{4}","\\d{10}",null,null,"6644923456"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"MS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"664",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"9(?:11|99)","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"MT":[null,[null,null,"[2357-9]\\d{7}","\\d{8}"],[null,null,"2(?:0(?:1[0-6]|[69]\\d)|[1-357]\\d{2})\\d{4}","\\d{8}",null,null,"21001234"],[null,null,"(?:7(?:210|[79]\\d{2})|9(?:2(?:1[01]|31)|696|8(?:1[1-3]|89|97)|9\\d{2}))\\d{4}","\\d{8}",null,null,"96961234"],[null,null,"800[3467]\\d{4}","\\d{8}",null,null,"80071234"],[null,null,"5(?:0(?:0(?:37|43)|6\\d{2}|70\\d|9[0168])|[12]\\d0[1-5])\\d{3}","\\d{8}",null,null,"50037123"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"3550\\d{4}","\\d{8}",null,null,"35501234"],"MT",356,"00",null,null,null,null,null,null,null,[[null,"(\\d{4})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"7117\\d{4}","\\d{8}",null,null,"71171234"],null,null,[null,null,"NA","NA"],[null,null,"501\\d{5}","\\d{8}",null,null,"50112345"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"MU":[null,[null,null,"[2-9]\\d{6,7}","\\d{7,8}"],[null,null,"(?:2(?:[03478]\\d|1[0-7]|6[1-69])|4(?:[013-68]\\d|2[4-7]|71)|5(44\\d|471|)|6\\d{2}|8(?:14|3[129]))\\d{4}","\\d{7,8}",null,null,"2012345"],[null,null,"5?(?:2[59]\\d|4(?:2[1-389]|4\\d|7[1-9]|9\\d)|7\\d{2}|8(?:[26]\\d|7[15-8])|9[0-8]\\d)\\d{4}","\\d{7,8}",null,null,"52512345"],[null,null,"80[012]\\d{4}","\\d{7}",null,null,"8001234"],[null,null,"30\\d{5}","\\d{7}",null,null,"3012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"3(?:20|9\\d)\\d{4}","\\d{7}",null,null,"3201234"],"MU",230,"0(?:0|[2-7]0|33)",null,null,null,null,null,"020",null,[[null,"([2-46-9]\\d{2})(\\d{4})","$1 $2",["[2-46-9]"],"","",0],[null,"(5\\d{3})(\\d{4})","$1 $2",["5"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[45]|99[59]","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"MV":[null,[null,null,"[3467]\\d{6}|9(?:00\\d{7}|\\d{6})","\\d{7,10}"],[null,null,"(?:3(?:0[01]|3[0-59])|6(?:[567][02468]|8[024689]|90))\\d{4}","\\d{7}",null,null,"6701234"],[null,null,"(?:46[46]|7[3-9]\\d|9[16-9]\\d)\\d{4}","\\d{7}",null,null,"7712345"],[null,null,"NA","NA"],[null,null,"900\\d{7}","\\d{10}",null,null,"9001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MV",960,"0(?:0|19)",null,null,null,null,null,"00",null,[[null,"(\\d{3})(\\d{4})","$1-$2",["[3467]|9(?:[1-9]|0[1-9])"],"","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["900"],"","",0]],null,[null,null,"781\\d{4}","\\d{7}",null,null,"7812345"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:02|19)","\\d{3}",null,null,"102"],[null,null,"NA","NA"]],"MW":[null,[null,null,"(?:1(?:\\d{2})?|[2789]\\d{2})\\d{6}","\\d{7,9}"],[null,null,"(?:1[2-9]|21\\d{2})\\d{5}","\\d{7,9}",null,null,"1234567"],[null,null,"(?:111|77\\d|88\\d|99\\d)\\d{6}","\\d{9}",null,null,"991234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MW",265,"00","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1"],"0$1","",0],[null,"(2\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[1789]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"199|99[789]","\\d{3}",null,null,"997"],[null,null,"NA","NA"]],"MX":[null,[null,null,"[1-9]\\d{9,10}","\\d{7,11}"],[null,null,"(?:33|55|81)\\d{8}|(?:2(?:2[2-9]|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|7[1-8]|9[1-5])|4(?:1[1-57-9]|[24-6][1-9]|[37][1-8]|8[1-35-9]|9[2-689])|5(?:88|9[1-79])|6(?:1[2-68]|[234][1-9]|5[1-3689]|6[12457-9]|7[1-7]|8[67]|9[4-8])|7(?:[13467][1-9]|2[1-8]|5[13-9]|8[1-69]|9[17])|8(?:2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[1-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69][1-9]|7[12]|8[1-8]))\\d{7}","\\d{7,10}",null,null,"2221234567"],[null,null,"1(?:(?:33|55|81)\\d{8}|(?:2(?:2[2-9]|3[1-35-8]|4[13-9]|7[1-689]|8[1-578]|9[467])|3(?:1[1-79]|[2458][1-9]|7[1-8]|9[1-5])|4(?:1[1-57-9]|[24-6][1-9]|[37][1-8]|8[1-35-9]|9[2-689])|5(?:88|9[1-79])|6(?:1[2-68]|[2-4][1-9]|5[1-3689]|6[12457-9]|7[1-7]|8[67]|9[4-8])|7(?:[13467][1-9]|2[1-8]|5[13-9]|8[1-69]|9[17])|8(?:2[13-689]|3[1-6]|4[124-6]|6[1246-9]|7[1-378]|9[12479])|9(?:1[346-9]|2[1-4]|3[2-46-8]|5[1348]|[69][1-9]|7[12]|8[1-8]))\\d{7})","\\d{11}",null,null,"12221234567"],[null,null,"800\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"900\\d{7}","\\d{10}",null,null,"9001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MX",52,"0[09]","01",null,null,"0[12]|04[45](\\d{10})","1$1",null,null,[[null,"([358]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["33|55|81"],"01 $1","",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2467]|3[12457-9]|5[89]|8[02-9]|9[0-35-9]"],"01 $1","",1],[null,"(1)([358]\\d)(\\d{4})(\\d{4})","044 $2 $3 $4",["1(?:33|55|81)"],"$1","",0],[null,"(1)(\\d{3})(\\d{3})(\\d{4})","044 $2 $3 $4",["1(?:[2467]|3[12457-9]|5[89]|8[2-9]|9[1-35-9])"],"$1","",0]],[[null,"([358]\\d)(\\d{4})(\\d{4})","$1 $2 $3",["33|55|81","33|55|81"],"01 $1","",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2467]|3[12457-9]|5[89]|8[02-9]|9[0-35-9]","[2467]|3[12457-9]|5[89]|8[02-9]|9[0-35-9]"],"01 $1","",1],[null,"(1)([358]\\d)(\\d{4})(\\d{4})","$1 $2 $3 $4",["1(?:33|55|81)"]],[null,"(1)(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1(?:[2467]|3[12457-9]|5[89]|8[2-9]|9[1-35-9])"]]],[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"06[568]|911","\\d{3}",null,null,"066"],[null,null,"NA","NA"]],"MY":[null,[null,null,"[13-9]\\d{7,9}","\\d{6,10}"],[null,null,"(?:3[2-9]\\d|[4-9][2-9])\\d{6}","\\d{6,9}",null,null,"323456789"],[null,null,"1(?:1[1-3]\\d{2}|[02-4679][2-9]\\d|59\\d{2}|8(?:1[23]|[2-9]\\d))\\d{5}","\\d{9,10}",null,null,"123456789"],[null,null,"1[38]00\\d{6}","\\d{10}",null,null,"1300123456"],[null,null,"1600\\d{6}","\\d{10}",null,null,"1600123456"],[null,null,"NA","NA"],[null,null,"1700\\d{6}","\\d{10}",null,null,"1700123456"],[null,null,"154\\d{7}","\\d{10}",null,null,"1541234567"],"MY",60,"00","0",null,null,"0",null,null,null,[[null,"([4-79])(\\d{3})(\\d{4})","$1-$2 $3",["[4-79]"],"0$1","",0],[null,"(3)(\\d{4})(\\d{4})","$1-$2 $3",["3"],"0$1","",0],[null,"([18]\\d)(\\d{3})(\\d{3,4})","$1-$2 $3",["1[02-46-9][1-9]|8"],"0$1","",0],[null,"(1)([36-8]00)(\\d{2})(\\d{4})","$1-$2-$3-$4",["1[36-8]0"],"","",0],[null,"(11)(\\d{4})(\\d{4})","$1-$2 $3",["11"],"0$1","",0],[null,"(15[49])(\\d{3})(\\d{4})","$1-$2 $3",["15"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"MZ":[null,[null,null,"[28]\\d{7,8}","\\d{8,9}"],[null,null,"2(?:[1346]\\d|5[0-2]|[78][12]|93)\\d{5}","\\d{8}",null,null,"21123456"],[null,null,"8[246]\\d{7}","\\d{9}",null,null,"821234567"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MZ",258,"00",null,null,null,null,null,null,null,[[null,"([28]\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["2|8[246]"],"","",0],[null,"(80\\d)(\\d{3})(\\d{3})","$1 $2 $3",["80"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:1[79]|9[78])","\\d{3}",null,null,"119"],[null,null,"NA","NA"]],"NA":[null,[null,null,"[68]\\d{7,8}","\\d{8,9}"],[null,null,"6(?:1(?:17|2(?:[0189]\\d|[2-6]|7\\d?)|3(?:2\\d|3[378])|4[01]|69|7[014])|2(?:17|25|5(?:[0-36-8]|4\\d?)|69|70)|3(?:17|2(?:[0237]\\d?|[14-689])|34|6[29]|7[01]|81)|4(?:17|2(?:[012]|7?)|4(?:[06]|1\\d)|5(?:[01357]|[25]\\d?)|69|7[01])|5(?:17|2(?:[0459]|[23678]\\d?)|69|7[01])|6(?:17|2(?:5|6\\d?)|38|42|69|7[01])|7(?:17|2(?:[569]|[234]\\d?)|3(?:0\\d?|[13])|69|7[01]))\\d{4}","\\d{8,9}",null,null,"61221234"],[null,null,"(?:60|8[125])\\d{7}","\\d{9}",null,null,"811234567"],[null,null,"NA","NA"],[null,null,"8701\\d{5}","\\d{9}",null,null,"870123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"8(3\\d{2}|86)\\d{5}","\\d{8,9}",null,null,"88612345"],"NA",264,"00","0",null,null,"0",null,null,null,[[null,"(8\\d)(\\d{3})(\\d{4})","$1 $2 $3",["8[1235]"],"0$1","",0],[null,"(6\\d)(\\d{2,3})(\\d{4})","$1 $2 $3",["6"],"0$1","",0],[null,"(88)(\\d{3})(\\d{3})","$1 $2 $3",["88"],"0$1","",0],[null,"(870)(\\d{3})(\\d{3})","$1 $2 $3",["870"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"10111","\\d{5}",null,null,"10111"],[null,null,"NA","NA"]],"NC":[null,[null,null,"[2-47-9]\\d{5}","\\d{6}"],[null,null,"(?:2[03-9]|3[0-5]|4[1-7]|88)\\d{4}","\\d{6}",null,null,"201234"],[null,null,"(?:[79]\\d|8[0-79])\\d{4}","\\d{6}",null,null,"751234"],[null,null,"NA","NA"],[null,null,"36\\d{4}","\\d{6}",null,null,"366711"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"NC",687,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})","$1.$2.$3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[5-8]","\\d{2}",null,null,"15"],[null,null,"NA","NA"]],"NE":[null,[null,null,"[0289]\\d{7}","\\d{8}"],[null,null,"2(?:0(?:20|3[1-7]|4[134]|5[14]|6[14578]|7[1-578])|1(?:4[145]|5[14]|6[14-68]|7[169]|88))\\d{4}","\\d{8}",null,null,"20201234"],[null,null,"(?:89|9[0-46-9])\\d{6}","\\d{8}",null,null,"93123456"],[null,null,"08\\d{6}","\\d{8}",null,null,"08123456"],[null,null,"09\\d{6}","\\d{8}",null,null,"09123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"NE",227,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[289]|09"],"","",0],[null,"(08)(\\d{3})(\\d{3})","$1 $2 $3",["08"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"NA","NA"],[null,null,"NA","NA"]],"NF":[null,[null,null,"[13]\\d{5}","\\d{5,6}"],[null,null,"(?:1(?:06|17|28|39)|3[012]\\d)\\d{3}","\\d{5,6}",null,null,"106609"],[null,null,"38\\d{4}","\\d{5,6}",null,null,"381234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"NF",672,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{4})","$1 $2",["1"],"","",0],[null,"(\\d)(\\d{5})","$1 $2",["3"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"9(?:11|55|77)","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"NG":[null,[null,null,"[1-69]\\d{5,8}|[78]\\d{5,13}","\\d{5,14}"],[null,null,"[12]\\d{6,7}|9\\d{7}|(?:3\\d|4[023568]|5[02368]|6[02-469]|7[4-69]|8[2-9])\\d{6}|(?:4[47]|5[14579]|6[1578]|7[0-357])\\d{5,6}|(?:78|41)\\d{5}","\\d{5,9}",null,null,"12345678"],[null,null,"(?:1(?:7[34]\\d|8(?:04|[124579]\\d|8[0-3])|95\\d)|287[0-7]|3(?:18[1-8]|88[0-7]|9(?:8[5-9]|6[1-5]))|4(?:28[0-2]|6(?:7[1-9]|8[02-47])|88[0-2])|5(?:2(?:7[7-9]|8\\d)|38[1-79]|48[0-7]|68[4-7])|6(?:2(?:7[7-9]|8\\d)|4(?:3[7-9]|[68][129]|7[04-69]|9[1-8])|58[0-2]|98[7-9])|7(?:38[0-7]|69[1-8]|78[2-4])|8(?:28[3-9]|38[0-2]|4(?:2[12]|3[147-9]|5[346]|7[4-9]|8[014-689]|90)|58[1-8]|78[2-9]|88[5-7])|98[07]\\d)\\d{4}|(?:70(?:[13-9]\\d|2[1-9])|8(?:0[2-9]|1\\d)\\d)\\d{6}","\\d{8,10}",null,null,"8021234567"],[null,null,"800\\d{7,11}","\\d{10,14}",null,null,"80017591759"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"NG",234,"009","0",null,null,"0",null,null,null,[[null,"([129])(\\d{3})(\\d{3,4})","$1 $2 $3",["[129]"],"0$1","",0],[null,"([3-8]\\d)(\\d{3})(\\d{2,3})","$1 $2 $3",["[3-6]|7(?:[1-79]|0[1-9])|8[2-9]"],"0$1","",0],[null,"([78]\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["70|8[01]"],"0$1","",0],[null,"([78]00)(\\d{4})(\\d{4,5})","$1 $2 $3",["[78]00"],"0$1","",0],[null,"([78]00)(\\d{5})(\\d{5,6})","$1 $2 $3",["[78]00"],"0$1","",0],[null,"(78)(\\d{2})(\\d{3})","$1 $2 $3",["78"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"700\\d{7,11}","\\d{10,14}",null,null,"7001234567"],null,[null,null,"199","\\d{3}",null,null,"199"],[null,null,"NA","NA"]],"NI":[null,[null,null,"[128]\\d{7}","\\d{8}"],[null,null,"2\\d{7}","\\d{8}",null,null,"21234567"],[null,null,"8\\d{7}","\\d{8}",null,null,"81234567"],[null,null,"1800\\d{4}","\\d{8}",null,null,"18001234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"NI",505,"00",null,null,null,null,null,null,null,[[null,"(\\d{4})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"118","\\d{3}",null,null,"118"],[null,null,"NA","NA"]],"NL":[null,[null,null,"1\\d{4,8}|[2-7]\\d{8}|[89]\\d{6,9}","\\d{5,10}"],[null,null,"(?:1[0135-8]|2[02-69]|3[0-68]|4[0135-9]|[57]\\d|8[478])\\d{7}","\\d{9}",null,null,"101234567"],[null,null,"6[1-58]\\d{7}","\\d{9}",null,null,"612345678"],[null,null,"800\\d{4,7}","\\d{7,10}",null,null,"8001234"],[null,null,"90[069]\\d{4,7}","\\d{7,10}",null,null,"9001234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"85\\d{7}","\\d{9}",null,null,"851234567"],"NL",31,"00","0",null,null,"0",null,null,null,[[null,"([1-578]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1[035]|2[0346]|3[03568]|4[0356]|5[0358]|7|8[4578]"],"0$1","",0],[null,"([1-5]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["1[16-8]|2[259]|3[124]|4[17-9]|5[124679]"],"0$1","",0],[null,"(6)(\\d{8})","$1 $2",["6[0-57-9]"],"0$1","",0],[null,"(66)(\\d{7})","$1 $2",["66"],"0$1","",0],[null,"(14)(\\d{3,4})","$1 $2",["14"],"$1","",0],[null,"([89]0\\d)(\\d{4,7})","$1 $2",["80|9"],"0$1","",0]],null,[null,null,"66\\d{7}","\\d{9}",null,null,"662345678"],null,null,[null,null,"14\\d{3,4}","\\d{5,6}"],[null,null,"140(?:1(?:[035]|[16-8]\\d)|2(?:[0346]|[259]\\d)|3(?:[03568]|[124]\\d)|4(?:[0356]|[17-9]\\d)|5(?:[0358]|[124679]\\d)|7\\d|8[458])","\\d{5,6}",null,null,"14020"],null,[null,null,"112|911","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"NO":[null,[null,null,"0\\d{4}|[2-9]\\d{7}","\\d{5}(?:\\d{3})?"],[null,null,"(?:2[1-4]|3[1-3578]|5[1-35-7]|6[1-4679]|7[0-8])\\d{6}","\\d{8}",null,null,"21234567"],[null,null,"(?:4[015-8]|5[89]|9\\d)\\d{6}","\\d{8}",null,null,"41234567"],[null,null,"80[01]\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"82[09]\\d{5}","\\d{8}",null,null,"82012345"],[null,null,"810(?:0[0-6]|[2-8]\\d)\\d{3}","\\d{8}",null,null,"81021234"],[null,null,"880\\d{5}","\\d{8}",null,null,"88012345"],[null,null,"85[0-5]\\d{5}","\\d{8}",null,null,"85012345"],"NO",47,"00",null,null,null,null,null,null,null,[[null,"([489]\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["[489]"],"","",0],[null,"([235-7]\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[235-7]"],"","",0]],null,[null,null,"NA","NA"],1,null,[null,null,"NA","NA"],[null,null,"0\\d{4}|81(?:0(?:0[7-9]|1\\d)|5\\d{2})\\d{3}","\\d{5}(?:\\d{3})?",null,null,"01234"],1,[null,null,"11[023]","\\d{3}",null,null,"112"],[null,null,"81[23]\\d{5}","\\d{8}",null,null,"81212345"]],"NP":[null,[null,null,"[1-8]\\d{7}|9(?:[1-69]\\d{6}|7[2-6]\\d{5,7}|8\\d{8})","\\d{6,10}"],[null,null,"(?:1[0124-6]|2[13-79]|3[135-8]|4[146-9]|5[135-7]|6[13-9]|7[15-9]|8[1-46-9]|9[1-79])\\d{6}","\\d{6,8}",null,null,"14567890"],[null,null,"9(?:7[45]|8[01456])\\d{7}","\\d{10}",null,null,"9841234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"NP",977,"00","0",null,null,"0",null,null,null,[[null,"(1)(\\d{7})","$1-$2",["1[2-6]"],"0$1","",0],[null,"(\\d{2})(\\d{6})","$1-$2",["1[01]|[2-8]|9(?:[1-69]|7[15-9])"],"0$1","",0],[null,"(9\\d{2})(\\d{7})","$1-$2",["9(?:7[45]|8)"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:0[0-3]|12)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"NR":[null,[null,null,"[458]\\d{6}","\\d{7}"],[null,null,"(?:444|888)\\d{4}","\\d{7}",null,null,"4441234"],[null,null,"55[5-9]\\d{4}","\\d{7}",null,null,"5551234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"NR",674,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[0-2]","\\d{3}",null,null,"110"],[null,null,"NA","NA"]],"NU":[null,[null,null,"[1-5]\\d{3}","\\d{4}"],[null,null,"[34]\\d{3}","\\d{4}",null,null,"4002"],[null,null,"[125]\\d{3}","\\d{4}",null,null,"1234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"NU",683,"00",null,null,null,null,null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"NZ":[null,[null,null,"6[235-9]\\d{6}|[2-57-9]\\d{7,10}","\\d{7,11}"],[null,null,"(?:3[2-79]|[49][2-689]|6[235-9]|7[2-5789])\\d{6}|24099\\d{3}","\\d{7,8}",null,null,"32345678"],[null,null,"2(?:[028]\\d{7,8}|1(?:0\\d{5,7}|[12]\\d{5,6}|[3-9]\\d{5})|[79]\\d{7})","\\d{8,10}",null,null,"211234567"],[null,null,"508\\d{6,7}|80\\d{6,8}","\\d{8,10}",null,null,"800123456"],[null,null,"90\\d{7,9}","\\d{9,11}",null,null,"900123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"NZ",64,"0(?:0|161)","0",null,null,"0",null,"00",null,[[null,"([34679])(\\d{3})(\\d{4})","$1-$2 $3",["[3467]|9[1-9]"],"0$1","",0],[null,"(24099)(\\d{3})","$1 $2",["240","2409","24099"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["21"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:1[1-9]|[69]|7[0-35-9])|86"],"0$1","",0],[null,"(2\\d)(\\d{3,4})(\\d{4})","$1 $2 $3",["2[028]"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:10|74)|5|[89]0"],"0$1","",0]],null,[null,null,"[28]6\\d{6,7}","\\d{8,9}",null,null,"26123456"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"111","\\d{3}",null,null,"111"],[null,null,"NA","NA"]],"OM":[null,[null,null,"(?:2[2-6]|5|9[1-9])\\d{6}|800\\d{5,6}","\\d{7,9}"],[null,null,"2[2-6]\\d{6}","\\d{8}",null,null,"23123456"],[null,null,"9[1-9]\\d{6}","\\d{8}",null,null,"92123456"],[null,null,"8007\\d{4,5}|500\\d{4}","\\d{7,9}",null,null,"80071234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"OM",968,"00",null,null,null,null,null,null,null,[[null,"(2\\d)(\\d{6})","$1 $2",["2"],"","",0],[null,"(9\\d{3})(\\d{4})","$1 $2",["9"],"","",0],[null,"([58]00)(\\d{4,6})","$1 $2",["[58]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"9999","\\d{4}",null,null,"9999"],[null,null,"NA","NA"]],"PA":[null,[null,null,"[1-9]\\d{6,7}","\\d{7,8}"],[null,null,"(?:1(?:0[02-579]|19|2[37]|3[03]|4[479]|57|65|7[016-8]|8[58]|9[134])|2(?:[0235679]\\d|1[0-7]|4[04-9]|8[028])|3(?:0[0-7]|1[14-7]|2[0-3]|3[03]|4[0457]|5[56]|6[068]|7[078]|80|9\\d)|4(?:3[013-59]|4\\d|7[0-689])|5(?:[01]\\d|2[0-7]|[56]0|79)|7(?:0[09]|2[0-267]|[349]0|5[6-9]|7[0-24-7]|8[89])|8(?:[34]\\d|5[0-4]|8[02])|9(?:0[78]|1[0178]|2[0378]|3[379]|40|5[0489]|6[06-9]|7[046-9]|8[36-8]|9[1-9]))\\d{4}","\\d{7}",null,null,"2001234"],[null,null,"(?:1[16]1|21[89]|8(?:1[01]|7[23]))\\d{4}|6(?:[04-9]\\d|1[0-5]|2[0-7]|3[5-9])\\d{5}","\\d{7,8}",null,null,"60012345"],[null,null,"80[09]\\d{4}","\\d{7}",null,null,"8001234"],[null,null,"(?:779|8(?:2[235]|55|60|7[578]|86|95)|9(?:0[0-2]|81))\\d{4}","\\d{7}",null,null,"8601234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"PA",507,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1-$2",["[1-57-9]"],"","",0],[null,"(\\d{4})(\\d{4})","$1-$2",["6"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"PE":[null,[null,null,"[14-9]\\d{7,8}","\\d{6,9}"],[null,null,"(?:1\\d|4[1-4]|5[1-46]|6[1-7]|7[2-46]|8[2-4])\\d{6}","\\d{6,8}",null,null,"11234567"],[null,null,"9\\d{8}","\\d{9}",null,null,"912345678"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"805\\d{5}","\\d{8}",null,null,"80512345"],[null,null,"801\\d{5}","\\d{8}",null,null,"80112345"],[null,null,"80[24]\\d{5}","\\d{8}",null,null,"80212345"],[null,null,"NA","NA"],"PE",51,"19(?:1[124]|77|90)00","0"," Anexo ",null,"0",null,null,null,[[null,"(1)(\\d{7})","$1 $2",["1"],"(0$1)","",0],[null,"([4-8]\\d)(\\d{6})","$1 $2",["[4-7]|8[2-4]"],"(0$1)","",0],[null,"(\\d{3})(\\d{5})","$1 $2",["80"],"(0$1)","",0],[null,"(9\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:05|1[67])","\\d{3}",null,null,"105"],[null,null,"NA","NA"]],"PF":[null,[null,null,"[2-79]\\d{5}|8\\d{5,7}","\\d{6}(?:\\d{2})?"],[null,null,"(?:4(?:[02-9]\\d|1[02-9])|[5689]\\d{2})\\d{3}","\\d{6}",null,null,"401234"],[null,null,"(?:[27]\\d{2}|3[0-79]\\d|411|89\\d{3})\\d{3}","\\d{6}(?:\\d{2})?",null,null,"212345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"PF",689,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["89"],"","",0],[null,"(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"44\\d{4}","\\d{6}",null,null,"441234"],[null,null,"NA","NA"],null,[null,null,"1[578]","\\d{2}",null,null,"15"],[null,null,"NA","NA"]],"PG":[null,[null,null,"[1-9]\\d{6,7}","\\d{7,8}"],[null,null,"(?:3\\d{2}|4[257]\\d|5[34]\\d|6(?:29|4[1-9])|85[02-46-9]|9[78]\\d)\\d{4}","\\d{7}",null,null,"3123456"],[null,null,"(?:68|7[0-36]\\d)\\d{5}","\\d{7,8}",null,null,"6812345"],[null,null,"180\\d{4}","\\d{7}",null,null,"1801234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"275\\d{4}","\\d{7}",null,null,"2751234"],"PG",675,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",["[1-689]"],"","",0],[null,"(7\\d{2})(\\d{2})(\\d{3})","$1 $2 $3",["7"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"000","\\d{3}",null,null,"000"],[null,null,"NA","NA"]],"PH":[null,[null,null,"2\\d{5,7}|[3-9]\\d{7,9}|1800\\d{7,9}","\\d{5,13}"],[null,null,"2\\d{5}(?:\\d{2})?|(?:3[2-68]|4[2-9]|5[2-6]|6[2-58]|7[24578]|8[2-8])\\d{7}|88(?:22\\d{6}|42\\d{4})","\\d{5,10}",null,null,"21234567"],[null,null,"(?:81[37]|9(?:0[5-9]|1[025-9]|2[0-35-9]|3[02-9]|4[236-9]|7[3479]|89|9[46-9]))\\d{7}","\\d{10}",null,null,"9051234567"],[null,null,"1800\\d{7,9}","\\d{11,13}",null,null,"180012345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"PH",63,"00","0",null,null,"0",null,null,null,[[null,"(2)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"(0$1)","",0],[null,"(2)(\\d{5})","$1 $2",["2"],"(0$1)","",0],[null,"(\\d{4})(\\d{4,6})","$1 $2",["3(?:23|39|46)|4(?:2[3-6]|[35]9|4[26]|76)|5(?:22|44)|642|8(?:62|8[245])","3(?:230|397|461)|4(?:2(?:35|[46]4|51)|396|4(?:22|63)|59[347]|76[15])|5(?:221|446)|642[23]|8(?:622|8(?:[24]2|5[13]))"],"(0$1)","",0],[null,"(\\d{5})(\\d{4})","$1 $2",["346|4(?:27|9[35])|883","3469|4(?:279|9(?:30|56))|8834"],"(0$1)","",0],[null,"([3-8]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[3-8]"],"(0$1)","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["81|9"],"0$1","",0],[null,"(1800)(\\d{3})(\\d{4})","$1 $2 $3",["1"],"","",0],[null,"(1800)(\\d{1,2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[27]|911","\\d{3}",null,null,"117"],[null,null,"NA","NA"]],"PK":[null,[null,null,"1\\d{8}|[2-8]\\d{5,11}|9(?:[013-9]\\d{4,9}|2\\d(?:111\\d{6}|\\d{3,7}))","\\d{6,12}"],[null,null,"(?:21|42)[2-9]\\d{7}|(?:2[25]|4[0146-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]\\d{6}|(?:2(?:3[2358]|4[2-4]|9[2-8])|45[3479]|54[2-467]|60[468]|72[236]|8(?:2[2-689]|3[23578]|4[3478]|5[2356])|9(?:1|2[2-8]|3[27-9]|4[2-6]|6[3569]|9[25-8]))[2-9]\\d{5,6}|58[126]\\d{7}","\\d{6,10}",null,null,"2123456789"],[null,null,"3(?:0\\d|1[1-5]|2[0-5]|3[1-6]|4[1-7]|55|64)\\d{7}","\\d{10}",null,null,"3012345678"],[null,null,"800\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"900\\d{5}","\\d{8}",null,null,"90012345"],[null,null,"NA","NA"],[null,null,"122\\d{6}","\\d{9}",null,null,"122044444"],[null,null,"NA","NA"],"PK",92,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(111)(\\d{3})(\\d{3})","$1 $2 $3 $4",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)1","(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)11","(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)111"],"(0$1)","",0],[null,"(\\d{3})(111)(\\d{3})(\\d{3})","$1 $2 $3 $4",["2[349]|45|54|60|72|8[2-5]|9[2-9]","(?:2[349]|45|54|60|72|8[2-5]|9[2-9])\\d1","(?:2[349]|45|54|60|72|8[2-5]|9[2-9])\\d11","(?:2[349]|45|54|60|72|8[2-5]|9[2-9])\\d111"],"(0$1)","",0],[null,"(\\d{2})(\\d{7,8})","$1 $2",["(?:2[125]|4[0-246-9]|5[1-35-7]|6[1-8]|7[14]|8[16]|91)[2-9]"],"(0$1)","",0],[null,"(\\d{3})(\\d{6,7})","$1 $2",["2[349]|45|54|60|72|8[2-5]|9[2-9]","(?:2[349]|45|54|60|72|8[2-5]|9[2-9])\\d[2-9]"],"(0$1)","",0],[null,"(3\\d{2})(\\d{7})","$1 $2",["3"],"0$1","",0],[null,"([15]\\d{3})(\\d{5,6})","$1 $2",["58[12]|1"],"(0$1)","",0],[null,"(586\\d{2})(\\d{5})","$1 $2",["586"],"(0$1)","",0],[null,"([89]00)(\\d{3})(\\d{2})","$1 $2 $3",["[89]00"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"(?:2(?:[125]|3[2358]|4[2-4]|9[2-8])|4(?:[0-246-9]|5[3479])|5(?:[1-35-7]|4[2-467])|6(?:[1-8]|0[468])|7(?:[14]|2[236])|8(?:[16]|2[2-689]|3[23578]|4[3478]|5[2356])|9(?:1|22|3[27-9]|4[2-6]|6[3569]|9[2-7]))111\\d{6}","\\d{11,12}",null,null,"21111825888"],null,[null,null,"1(?:1(?:22?|5)|[56])","\\d{2,4}",null,null,"112"],[null,null,"NA","NA"]],"PL":[null,[null,null,"[1-58]\\d{6,8}|9\\d{8}|[67]\\d{5,8}","\\d{6,9}"],[null,null,"(?:1[2-8]|2[2-59]|3[2-4]|4[1-468]|5[24-689]|6[1-3578]|7[14-6]|8[1-7])\\d{5,7}|77\\d{4,7}|(?:89|9[145])\\d{7}","\\d{6,9}",null,null,"123456789"],[null,null,"(?:5[013]|6[069]|7[2389]|88)\\d{7}","\\d{9}",null,null,"512345678"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"70\\d{7}","\\d{9}",null,null,"701234567"],[null,null,"801\\d{6}","\\d{9}",null,null,"801234567"],[null,null,"NA","NA"],[null,null,"39\\d{7}","\\d{9}",null,null,"391234567"],"PL",48,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[124]|3[2-4]|5[24-689]|6[1-3578]|7[14-7]|8[1-79]|9[145]"],"","",0],[null,"(\\d{2})(\\d{4,6})","$1 $2",["[124]|3[2-4]|5[24-689]|6[1-3578]|7[14-7]|8[1-7]"],"","",0],[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["39|5[013]|6[0469]|7[02389]|8[08]"],"","",0],[null,"(\\d{3})(\\d{2})(\\d{2,3})","$1 $2 $3",["64"],"","",0],[null,"(\\d{3})(\\d{3})","$1 $2",["64"],"","",0]],null,[null,null,"642\\d{3,6}","\\d{6,9}",null,null,"642123456"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|99[789]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"PM":[null,[null,null,"[45]\\d{5}","\\d{6}"],[null,null,"41\\d{4}","\\d{6}",null,null,"411234"],[null,null,"55\\d{4}","\\d{6}",null,null,"551234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"PM",508,"00","0",null,null,"0",null,null,null,[[null,"([45]\\d)(\\d{2})(\\d{2})","$1 $2 $3",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[578]","\\d{2}",null,null,"17"],[null,null,"NA","NA"]],"PR":[null,[null,null,"[5789]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"(?:787|939)[2-9]\\d{6}","\\d{7}(?:\\d{3})?",null,null,"7872345678"],[null,null,"(?:787|939)[2-9]\\d{6}","\\d{7}(?:\\d{3})?",null,null,"7872345678"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002345678"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002345678"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"PR",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,"NA","NA"],null,"787|939",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"PS":[null,[null,null,"[24589]\\d{7,8}|1(?:[78]\\d{8}|[49]\\d{2,3})","\\d{4,10}"],[null,null,"(?:22[234789]|42[45]|82[01458]|92[369])\\d{5}","\\d{7,8}",null,null,"22234567"],[null,null,"5[69]\\d{7}","\\d{9}",null,null,"599123456"],[null,null,"1800\\d{6}","\\d{10}",null,null,"1800123456"],[null,null,"1(?:4|9\\d)\\d{2}","\\d{4,5}",null,null,"19123"],[null,null,"1700\\d{6}","\\d{10}",null,null,"1700123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],"PS",970,"00","0",null,null,"0",null,null,null,[[null,"([2489])(2\\d{2})(\\d{4})","$1 $2 $3",["[2489]"],"0$1","",0],[null,"(5[69]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["5"],"0$1","",0],[null,"(1[78]00)(\\d{3})(\\d{3})","$1 $2 $3",["1[78]"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"PT":[null,[null,null,"[2-46-9]\\d{8}","\\d{9}"],[null,null,"2(?:[12]\\d|[35][1-689]|4[1-59]|6[1-35689]|7[1-9]|8[1-69]|9[1256])\\d{6}","\\d{9}",null,null,"212345678"],[null,null,"9(?:[136]\\d{2}|2[0-79]\\d|480)\\d{5}","\\d{9}",null,null,"912345678"],[null,null,"80[02]\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"76(?:0[1-57]|1[2-47]|2[237])\\d{5}","\\d{9}",null,null,"760123456"],[null,null,"80(?:8\\d|9[1579])\\d{5}","\\d{9}",null,null,"808123456"],[null,null,"884[128]\\d{5}","\\d{9}",null,null,"884123456"],[null,null,"30\\d{7}","\\d{9}",null,null,"301234567"],"PT",351,"00",null,null,null,null,null,null,null,[[null,"(2\\d)(\\d{3})(\\d{4})","$1 $2 $3",["2[12]"],"","",0],[null,"([2-46-9]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2[3-9]|[346-9]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"70(?:7\\d|8[17])\\d{5}","\\d{9}",null,null,"707123456"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"PW":[null,[null,null,"[2-8]\\d{6}","\\d{7}"],[null,null,"2552255|(?:277|345|488|5(?:35|44|87)|6(?:22|54|79)|7(?:33|47)|8(?:24|55|76))\\d{4}","\\d{7}",null,null,"2771234"],[null,null,"(?:6[234689]0|77[45789])\\d{4}","\\d{7}",null,null,"6201234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"PW",680,"01[12]",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"PY":[null,[null,null,"5[0-5]\\d{4,7}|[2-46-9]\\d{5,8}","\\d{5,9}"],[null,null,"(?:[26]1|3[289]|4[124678]|7[123]|8[1236])\\d{5,7}|(?:2(?:2[4568]|7[15]|9[1-5])|3(?:18|3[167]|4[2357]|51)|4(?:18|2[45]|3[12]|5[13]|64|71|9[1-47])|5(?:[1-4]\\d|5[0234])|6(?:3[1-3]|44|7[1-4678])|7(?:17|4[0-4]|6[1-578]|75|8[0-8])|858)\\d{5,6}","\\d{5,9}",null,null,"212345678"],[null,null,"9(?:6[12]|[78][1-6]|9[1-5])\\d{6}","\\d{9}",null,null,"961456789"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"8700[0-4]\\d{4}","\\d{9}",null,null,"870012345"],"PY",595,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{5,7})","$1 $2",["(?:[26]1|3[289]|4[124678]|7[123]|8[1236])"],"($1)","",0],[null,"(\\d{3})(\\d{3,6})","$1 $2",["[2-9]0"],"0$1","",0],[null,"(\\d{3})(\\d{6})","$1 $2",["9[1-9]"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["8700"],"","",0],[null,"(\\d{3})(\\d{4,6})","$1 $2",["[2-8][1-9]"],"($1)","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"[2-9]0\\d{4,7}","\\d{6,9}",null,null,"201234567"],null,[null,null,"128|911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"QA":[null,[null,null,"[2-8]\\d{6,7}","\\d{7,8}"],[null,null,"4[04]\\d{6}","\\d{7,8}",null,null,"44123456"],[null,null,"[3567]\\d{7}","\\d{7,8}",null,null,"33123456"],[null,null,"800\\d{4}","\\d{7,8}",null,null,"8001234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"QA",974,"00",null,null,null,null,null,null,null,[[null,"([28]\\d{2})(\\d{4})","$1 $2",["[28]"],"","",0],[null,"([3-7]\\d{3})(\\d{4})","$1 $2",["[3-7]"],"","",0]],null,[null,null,"2(?:[12]\\d|61)\\d{4}","\\d{7}",null,null,"2123456"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"RE":[null,[null,null,"[268]\\d{8}","\\d{9}"],[null,null,"262\\d{6}","\\d{9}",null,null,"262161234"],[null,null,"6(?:9[23]|47)\\d{6}","\\d{9}",null,null,"692123456"],[null,null,"80\\d{7}","\\d{9}",null,null,"801234567"],[null,null,"89[1-37-9]\\d{6}","\\d{9}",null,null,"891123456"],[null,null,"8(?:1[019]|2[0156]|84|90)\\d{6}","\\d{9}",null,null,"810123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],"RE",262,"00","0",null,null,"0",null,null,null,[[null,"([268]\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"0$1","",0]],null,[null,null,"NA","NA"],1,"262|6[49]|8",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:12|[578])","\\d{2,3}",null,null,"15"],[null,null,"NA","NA"]],"RO":[null,[null,null,"2\\d{5,8}|[37-9]\\d{8}","\\d{6,9}"],[null,null,"2(?:1(?:\\d{7}|9\\d{3})|[3-6](?:\\d{7}|\\d9\\d{2}))|3[13-6]\\d{7}","\\d{6,9}",null,null,"211234567"],[null,null,"7(?:000|[1-8]\\d{2}|99\\d)\\d{5}","\\d{9}",null,null,"712345678"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"90[036]\\d{6}","\\d{9}",null,null,"900123456"],[null,null,"801\\d{6}","\\d{9}",null,null,"801123456"],[null,null,"802\\d{6}","\\d{9}",null,null,"802123456"],[null,null,"NA","NA"],"RO",40,"00","0"," int ",null,"0",null,null,null,[[null,"([237]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[23]1"],"0$1","",0],[null,"(21)(\\d{4})","$1 $2",["21"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["[23][3-7]|[7-9]"],"0$1","",0],[null,"(2\\d{2})(\\d{3})","$1 $2",["2[3-6]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"37\\d{7}","\\d{9}",null,null,"372123456"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"RS":[null,[null,null,"[126-9]\\d{4,11}|3(?:[0-79]\\d{3,10}|8[2-9]\\d{2,9})","\\d{5,12}"],[null,null,"(?:1(?:[02-9][2-9]|1[1-9])\\d|2(?:[0-24-7][2-9]\\d|[389](?:0[2-9]|[2-9]\\d))|3(?:[0-8][2-9]\\d|9(?:[2-9]\\d|0[2-9])))\\d{3,8}","\\d{5,12}",null,null,"10234567"],[null,null,"6(?:[0-689]|7\\d)\\d{6,7}","\\d{8,10}",null,null,"601234567"],[null,null,"800\\d{3,9}","\\d{6,12}",null,null,"80012345"],[null,null,"(?:90[0169]|78\\d)\\d{3,7}","\\d{6,12}",null,null,"90012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"RS",381,"00","0",null,null,"0",null,null,null,[[null,"([23]\\d{2})(\\d{4,9})","$1 $2",["(?:2[389]|39)0"],"0$1","",0],[null,"([1-3]\\d)(\\d{5,10})","$1 $2",["1|2(?:[0-24-7]|[389][1-9])|3(?:[0-8]|9[1-9])"],"0$1","",0],[null,"(6\\d)(\\d{6,8})","$1 $2",["6"],"0$1","",0],[null,"([89]\\d{2})(\\d{3,9})","$1 $2",["[89]"],"0$1","",0],[null,"(7[26])(\\d{4,9})","$1 $2",["7[26]"],"0$1","",0],[null,"(7[08]\\d)(\\d{4,9})","$1 $2",["7[08]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"7[06]\\d{4,10}","\\d{6,12}",null,null,"700123456"],null,[null,null,"112|9[234]","\\d{2,3}",null,null,"112"],[null,null,"NA","NA"]],"RU":[null,[null,null,"[3489]\\d{9}","\\d{10}"],[null,null,"(?:3(?:0[12]|4[1-35-79]|5[1-3]|8[1-58]|9[0145])|4(?:01|1[1356]|2[13467]|7[1-5]|8[1-7]|9[1-689])|8(?:1[1-8]|2[01]|3[13-6]|4[0-8]|5[15]|6[1-35-7]|7[1-37-9]))\\d{7}","\\d{10}",null,null,"3011234567"],[null,null,"9\\d{9}","\\d{10}",null,null,"9123456789"],[null,null,"80[04]\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"80[39]\\d{7}","\\d{10}",null,null,"8091234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"RU",7,"810","8",null,null,"8",null,"8~10",null,[[null,"(\\d{3})(\\d{2})(\\d{2})","$1-$2-$3",["[1-79]"],"$1","",0],[null,"([3489]\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[34689]"],"8 ($1)","",1],[null,"(7\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7"],"8 ($1)","",1]],[[null,"([3489]\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2-$3-$4",["[34689]","[34689]"],"8 ($1)","",1],[null,"(7\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["7","7"],"8 ($1)","",1]],[null,null,"NA","NA"],1,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"0[123]|112","\\d{2,3}",null,null,"112"],[null,null,"NA","NA"]],"RW":[null,[null,null,"[027-9]\\d{7,8}","\\d{8,9}"],[null,null,"2[258]\\d{7}|06\\d{6}","\\d{8,9}",null,null,"250123456"],[null,null,"7[238]\\d{7}","\\d{9}",null,null,"720123456"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"900\\d{6}","\\d{9}",null,null,"900123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"RW",250,"00","0",null,null,"0",null,null,null,[[null,"(2\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["2"],"$1","",0],[null,"([7-9]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[7-9]"],"0$1","",0],[null,"(0\\d)(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["0"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"SA":[null,[null,null,"1\\d{7,8}|(?:[2-467]|92)\\d{7}|5\\d{8}|8\\d{9}","\\d{7,10}"],[null,null,"(?:11?\\d|2[24-8]|3[35-8]|4[3-68]|6[2-5]|7[235-7])\\d{6}","\\d{7,9}",null,null,"112345678"],[null,null,"(?:5[013-689]|811)\\d{7}","\\d{9,10}",null,null,"512345678"],[null,null,"800\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"NA","NA"],[null,null,"92[05]\\d{6}","\\d{9}",null,null,"920012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],"SA",966,"00","0",null,null,"0",null,null,null,[[null,"([1-467])(\\d{3})(\\d{4})","$1 $2 $3",["[1-467]"],"0$1","",0],[null,"(1\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1[1-467]"],"0$1","",0],[null,"(5\\d)(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1","",0],[null,"(92\\d{2})(\\d{5})","$1 $2",["9"],"$1","",0],[null,"(800)(\\d{3})(\\d{4})","$1 $2 $3",["80"],"$1","",0],[null,"(811)(\\d{3})(\\d{3,4})","$1 $2 $3",["81"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|9(?:11|9[7-9])","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"SB":[null,[null,null,"[1-9]\\d{4,6}","\\d{5,7}"],[null,null,"(?:1[4-79]|[23]\\d|4[01]|5[03]|6[0-37])\\d{3}","\\d{5}",null,null,"40123"],[null,null,"48\\d{3}|7(?:[46-8]\\d|5[025-9]|90)\\d{4}|8[4-8]\\d{5}|9(?:[46]\\d|5[0-46-9]|7[0-689]|8[0-79]|9[0-8])\\d{4}","\\d{5,7}",null,null,"7421234"],[null,null,"1[38]\\d{3}","\\d{5}",null,null,"18123"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"5[12]\\d{3}","\\d{5}",null,null,"51123"],"SB",677,"0[01]",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",["[7-9]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"SC":[null,[null,null,"[24689]\\d{5,6}","\\d{6,7}"],[null,null,"4[2-46]\\d{5}","\\d{7}",null,null,"4217123"],[null,null,"2[5-8]\\d{5}","\\d{7}",null,null,"2510123"],[null,null,"8000\\d{2}","\\d{6}",null,null,"800000"],[null,null,"98\\d{4}","\\d{6}",null,null,"981234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"64\\d{5}","\\d{7}",null,null,"6412345"],"SC",248,"0[0-2]",null,null,null,null,null,"00",null,[[null,"(\\d{3})(\\d{3})","$1 $2",["[89]"],"","",0],[null,"(\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[246]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"SD":[null,[null,null,"[19]\\d{8}","\\d{9}"],[null,null,"1(?:[125]\\d|8[3567])\\d{6}","\\d{9}",null,null,"121231234"],[null,null,"9[012569]\\d{7}","\\d{9}",null,null,"911231234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"SD",249,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"SE":[null,[null,null,"[1-9]\\d{6,9}","\\d{5,10}"],[null,null,"1(?:0[1-8]\\d{6}|[136]\\d{5,7}|(?:2[0-35]|4[0-4]|5[0-25-9]|7[13-6]|[89]\\d)\\d{5,6})|2(?:[136]\\d{5,7}|(?:2[0-7]|4[0136-8]|5[0138]|7[018]|8[01]|9[0-57])\\d{5,6})|3(?:[356]\\d{5,7}|(?:0[0-4]|1\\d|2[0-25]|4[056]|7[0-2]|8[0-3]|9[023])\\d{5,6})|4(?:[0246]\\d{5,7}|(?:1[0-8]|3[0135]|5[14-79]|7[0-246-9]|8[0156]|9[0-689])\\d{5,6})|5(?:0[0-6]|[15][0-5]|2[0-68]|3[0-4]|4\\d|6[03-5]|7[013]|8[0-79]|9[01])\\d{5,6}|6(?:[03]\\d{5,7}|(?:1[1-3]|2[0-4]|4[02-57]|5[0-37]|6[0-3]|7[0-2]|8[0247]|9[0-356])\\d{5,6})|8\\d{6,8}|9(?:0\\d{5,7}|(?:1[0-68]|2\\d|3[02-59]|[45][0-4]|[68][01]|7[0135-8])\\d{5,6})","\\d{5,9}",null,null,"8123456"],[null,null,"7[0236]\\d{7}","\\d{9}",null,null,"701234567"],[null,null,"20\\d{4,7}","\\d{6,9}",null,null,"201234567"],[null,null,"9(?:00|39|44)\\d{7}","\\d{10}",null,null,"9001234567"],[null,null,"77\\d{7}","\\d{9}",null,null,"771234567"],[null,null,"75\\d{7}","\\d{9}",null,null,"751234567"],[null,null,"NA","NA"],"SE",46,"00","0",null,null,"0",null,null,null,[[null,"(8)(\\d{2,3})(\\d{2,3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1","",0],[null,"([1-69]\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[013689]|2[0136]|3[1356]|4[0246]|54|6[03]|90"],"0$1","",0],[null,"([1-69]\\d)(\\d{3})(\\d{2})","$1-$2 $3",["1[13689]|2[136]|3[1356]|4[0246]|54|6[03]|90"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[2457]|2[2457-9]|3[0247-9]|4[1357-9]|5[0-35-9]|6[124-9]|9(?:[125-8]|3[0-5]|4[0-3])"],"0$1","",0],[null,"(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2[2457-9]|3[0247-9]|4[1357-9]|5[0-35-9]|6[124-9]|9(?:[125-8]|3[0-5]|4[0-3])"],"0$1","",0],[null,"(7\\d)(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["7"],"0$1","",0],[null,"(20)(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1","",0],[null,"(9[034]\\d)(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9[034]"],"0$1","",0]],[[null,"(8)(\\d{2,3})(\\d{2,3})(\\d{2})","$1 $2 $3 $4",["8"]],[null,"([1-69]\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[013689]|2[0136]|3[1356]|4[0246]|54|6[03]|90"]],[null,"([1-69]\\d)(\\d{3})(\\d{2})","$1 $2 $3",["1[13689]|2[136]|3[1356]|4[0246]|54|6[03]|90"]],[null,"(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["1[2457]|2[2457-9]|3[0247-9]|4[1357-9]|5[0-35-9]|6[124-9]|9(?:[125-8]|3[0-5]|4[0-3])"]],[null,"(\\d{3})(\\d{2,3})(\\d{2})","$1 $2 $3",["1[2457]|2[2457-9]|3[0247-9]|4[1357-9]|5[0-35-9]|6[124-9]|9(?:[125-8]|3[0-5]|4[0-3])"]],[null,"(7\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["7"]],[null,"(20)(\\d{2,3})(\\d{2})","$1 $2 $3",["20"]],[null,"(9[034]\\d)(\\d{2})(\\d{2})(\\d{3})","$1 $2 $3 $4",["9[034]"]]],[null,null,"74\\d{7}","\\d{9}",null,null,"741234567"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|90000","\\d{3,5}",null,null,"112"],[null,null,"NA","NA"]],"SG":[null,[null,null,"[36]\\d{7}|[17-9]\\d{7,10}","\\d{8,11}"],[null,null,"6[1-9]\\d{6}","\\d{8}",null,null,"61234567"],[null,null,"(?:8[1-7]|9[0-8])\\d{6}","\\d{8}",null,null,"81234567"],[null,null,"1?800\\d{7}","\\d{10,11}",null,null,"18001234567"],[null,null,"1900\\d{7}","\\d{11}",null,null,"19001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"3[12]\\d{6}","\\d{8}",null,null,"31234567"],"SG",65,"0[0-3]\\d",null,null,null,null,null,null,null,[[null,"([3689]\\d{3})(\\d{4})","$1 $2",["[369]|8[1-9]"],"","",0],[null,"(1[89]00)(\\d{3})(\\d{4})","$1 $2 $3",["1[89]"],"","",0],[null,"(7000)(\\d{4})(\\d{3})","$1 $2 $3",["70"],"","",0],[null,"(800)(\\d{3})(\\d{4})","$1 $2 $3",["80"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"7000\\d{7}","\\d{11}",null,null,"70001234567"],null,[null,null,"99[359]","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"SH":[null,[null,null,"[2-79]\\d{3,4}","\\d{4,5}"],[null,null,"2(?:[0-57-9]\\d|6[4-9])\\d{2}|(?:[2-46]\\d|7[01])\\d{2}","\\d{4,5}",null,null,"2158"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"(?:[59]\\d|7[2-9])\\d{2}","\\d{4,5}",null,null,"5012"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"SH",290,"00",null,null,null,null,null,null,null,null,null,[null,null,"NA","NA"],1,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"9(?:11|99)","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"SI":[null,[null,null,"[1-7]\\d{6,7}|[89]\\d{4,7}","\\d{5,8}"],[null,null,"(?:1\\d|[25][2-8]|3[4-8]|4[24-8]|7[3-8])\\d{6}","\\d{7,8}",null,null,"11234567"],[null,null,"(?:[37][01]|4[019]|51|6[48])\\d{6}","\\d{8}",null,null,"31234567"],[null,null,"80\\d{4,6}","\\d{6,8}",null,null,"80123456"],[null,null,"90\\d{4,6}|89[1-3]\\d{2,5}","\\d{5,8}",null,null,"90123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"(?:59|8[1-3])\\d{6}","\\d{8}",null,null,"59012345"],"SI",386,"00","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[12]|3[4-8]|4[24-8]|5[2-8]|7[3-8]"],"(0$1)","",0],[null,"([3-7]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["[37][01]|4[019]|51|6"],"0$1","",0],[null,"([89][09])(\\d{3,6})","$1 $2",["[89][09]"],"0$1","",0],[null,"([58]\\d{2})(\\d{5})","$1 $2",["59|8[1-3]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[23]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"SJ":[null,[null,null,"0\\d{4}|[4789]\\d{7}","\\d{5}(?:\\d{3})?"],[null,null,"79\\d{6}","\\d{8}",null,null,"79123456"],[null,null,"(?:4[015-8]|5[89]|9\\d)\\d{6}","\\d{8}",null,null,"41234567"],[null,null,"80[01]\\d{5}","\\d{8}",null,null,"80012345"],[null,null,"82[09]\\d{5}","\\d{8}",null,null,"82012345"],[null,null,"810(?:0[0-6]|[2-8]\\d)\\d{3}","\\d{8}",null,null,"81021234"],[null,null,"880\\d{5}","\\d{8}",null,null,"88012345"],[null,null,"85[0-5]\\d{5}","\\d{8}",null,null,"85012345"],"SJ",47,"00",null,null,null,null,null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"0\\d{4}|81(?:0(?:0[7-9]|1\\d)|5\\d{2})\\d{3}","\\d{5}(?:\\d{3})?",null,null,"01234"],1,[null,null,"11[023]","\\d{3}",null,null,"112"],[null,null,"81[23]\\d{5}","\\d{8}",null,null,"81212345"]],"SK":[null,[null,null,"[2-689]\\d{8}","\\d{9}"],[null,null,"[2-5]\\d{8}","\\d{9}",null,null,"212345678"],[null,null,"9(?:0[1-8]|1[0-24-9]|4[0489])\\d{6}","\\d{9}",null,null,"912123456"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"9(?:[78]\\d{7}|00\\d{6})","\\d{9}",null,null,"900123456"],[null,null,"8[5-9]\\d{7}","\\d{9}",null,null,"850123456"],[null,null,"NA","NA"],[null,null,"6(?:5[0-4]|9[0-6])\\d{6}","\\d{9}",null,null,"690123456"],"SK",421,"00","0",null,null,"0",null,null,null,[[null,"(2)(\\d{3})(\\d{3})(\\d{2})","$1/$2 $3 $4",["2"],"0$1","",0],[null,"([3-5]\\d)(\\d{3})(\\d{2})(\\d{2})","$1/$2 $3 $4",["[3-5]"],"0$1","",0],[null,"([689]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[689]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"(?:8(?:00|[5-9]\\d)|9(?:00|[78]\\d))\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"96\\d{7}","\\d{9}",null,null,"961234567"],null,[null,null,"1(?:12|5[058])","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"SL":[null,[null,null,"[2-578]\\d{7}","\\d{6,8}"],[null,null,"[235]2[2-4][2-9]\\d{4}","\\d{6,8}",null,null,"22221234"],[null,null,"(?:2[15]|3[034]|4[04]|5[05]|7[6-9]|88)\\d{6}","\\d{6,8}",null,null,"25123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"SL",232,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{6})","$1 $2",null,"(0$1)","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"(?:01|99)9","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"SM":[null,[null,null,"[05-7]\\d{7,9}","\\d{6,10}"],[null,null,"0549(?:8[0157-9]|9\\d)\\d{4}","\\d{6,10}",null,null,"0549886377"],[null,null,"6[16]\\d{6}","\\d{8}",null,null,"66661212"],[null,null,"NA","NA"],[null,null,"7[178]\\d{6}","\\d{8}",null,null,"71123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"5[158]\\d{6}","\\d{8}",null,null,"58001110"],"SM",378,"00",null,null,null,"(?:0549)?([89]\\d{5})","0549$1",null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]"],"","",0],[null,"(0549)(\\d{6})","$1 $2",["0"],"","",0],[null,"(\\d{6})","0549 $1",["[89]"],"","",0]],[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[5-7]","[5-7]"],"","",0],[null,"(0549)(\\d{6})","($1) $2",["0"]],[null,"(\\d{6})","(0549) $1",["[89]"]]],[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"11[358]","\\d{3}",null,null,"113"],[null,null,"NA","NA"]],"SN":[null,[null,null,"[37]\\d{8}","\\d{9}"],[null,null,"3(?:0(?:1[01]|80)|3(?:8[1-9]|9[2-9]))\\d{5}","\\d{9}",null,null,"301012345"],[null,null,"7(?:0(?:[01279]0|3[03]|4[05]|5[06]|6[03-5]|8[029])|6(?:1[23]|2[89]|3[3489]|4[6-9]|5\\d|6[3-9]|7[45]|8[3-8])|7\\d{2}|8(?:01|1[01]))\\d{5}","\\d{9}",null,null,"701012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"33301\\d{4}","\\d{9}",null,null,"333011234"],"SN",221,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"SO":[null,[null,null,"[1-79]\\d{6,8}","\\d{7,9}"],[null,null,"(?:[134]\\d|2[0-79]|5[57-9])\\d{5}","\\d{7}",null,null,"5522010"],[null,null,"(?:15\\d|2(?:4\\d|8)|6[137-9]?\\d{2}|7\\d{2}|9(?:07|[19])\\d)\\d{5}","\\d{7,9}",null,null,"907792024"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"SO",252,"00","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{6})","$1 $2",["2[0-79]|[13-5]"],"","",0],[null,"(\\d)(\\d{7})","$1 $2",["24|[67]"],"","",0],[null,"(\\d{2})(\\d{5,7})","$1 $2",["15|28|6[1378]|9"],"","",0],[null,"(69\\d)(\\d{6})","$1 $2",["69"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"SR":[null,[null,null,"[2-8]\\d{5,6}","\\d{6,7}"],[null,null,"(?:2[1-3]|3[0-7]|4\\d|5[2-58]|68\\d)\\d{4}","\\d{6,7}",null,null,"211234"],[null,null,"(?:7[1-57]|8[1-9])\\d{5}","\\d{7}",null,null,"7412345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"56\\d{4}","\\d{6}",null,null,"561234"],"SR",597,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{3})","$1-$2",["[2-4]|5[2-58]"],"","",0],[null,"(\\d{2})(\\d{2})(\\d{2})","$1-$2-$3",["56"],"","",0],[null,"(\\d{3})(\\d{4})","$1-$2",["[6-8]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"115","\\d{3}",null,null,"115"],[null,null,"NA","NA"]],"SS":[null,[null,null,"[19]\\d{8}","\\d{9}"],[null,null,"18\\d{7}","\\d{9}",null,null,"181234567"],[null,null,"(?:12|9[1257])\\d{7}","\\d{9}",null,null,"977123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"SS",211,"00","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"ST":[null,[null,null,"[29]\\d{6}","\\d{7}"],[null,null,"22\\d{5}","\\d{7}",null,null,"2221234"],[null,null,"9[89]\\d{5}","\\d{7}",null,null,"9812345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"ST",239,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"SV":[null,[null,null,"[267]\\d{7}|[89]\\d{6}(?:\\d{4})?","\\d{7,8}|\\d{11}"],[null,null,"2[1-6]\\d{6}","\\d{8}",null,null,"21234567"],[null,null,"[67]\\d{7}","\\d{8}",null,null,"70123456"],[null,null,"800\\d{4}(?:\\d{4})?","\\d{7}(?:\\d{4})?",null,null,"8001234"],[null,null,"900\\d{4}(?:\\d{4})?","\\d{7}(?:\\d{4})?",null,null,"9001234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"SV",503,"00",null,null,null,null,null,null,null,[[null,"(\\d{4})(\\d{4})","$1 $2",["[267]"],"","",0],[null,"(\\d{3})(\\d{4})","$1 $2",["[89]"],"","",0],[null,"(\\d{3})(\\d{4})(\\d{4})","$1 $2 $3",["[89]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"SX":[null,[null,null,"[5789]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"7215(?:4[2-8]|8[239]|9[056])\\d{4}","\\d{7}(?:\\d{3})?",null,null,"7215425678"],[null,null,"7215(?:1[02]|2\\d|5[034679]|8[014-8])\\d{4}","\\d{10}",null,null,"7215205678"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002123456"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002123456"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"SX",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"721",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"919","\\d{3}",null,null,"919"],[null,null,"NA","NA"]],"SY":[null,[null,null,"[1-59]\\d{7,8}","\\d{6,9}"],[null,null,"(?:1(?:1\\d?|4\\d|[2356])|2[1-35]|3(?:[13]\\d|4)|4[13]|5[1-3])\\d{6}","\\d{6,9}",null,null,"112345678"],[null,null,"9(?:22|[35][0-8]|4\\d|6[024-9]|88|9[0-489])\\d{6}","\\d{9}",null,null,"944567890"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"SY",963,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-5]"],"0$1","",1],[null,"(9\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9"],"0$1","",1]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[023]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"SZ":[null,[null,null,"[027]\\d{7}","\\d{8}"],[null,null,"2(?:2(?:0[07]|[13]7|2[57])|3(?:0[34]|[1278]3|3[23]|[46][34])|(?:40[4-69]|67)|5(?:0[5-7]|1[6-9]|[23][78]|48|5[01]))\\d{4}","\\d{8}",null,null,"22171234"],[null,null,"7[6-8]\\d{6}","\\d{8}",null,null,"76123456"],[null,null,"0800\\d{4}","\\d{8}",null,null,"08001234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"SZ",268,"00",null,null,null,null,null,null,null,[[null,"(\\d{4})(\\d{4})","$1 $2",["[027]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"0800\\d{4}","\\d{8}",null,null,"08001234"],[null,null,"NA","NA"],1,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"TA":[null,[null,null,"8\\d{3}","\\d{4}"],[null,null,"8\\d{3}","\\d{4}",null,null,"8999"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TA",290,"00",null,null,null,null,null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"TC":[null,[null,null,"[5689]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"649(?:712|9(?:4\\d|50))\\d{4}","\\d{7}(?:\\d{3})?",null,null,"6497121234"],[null,null,"649(?:2(?:3[129]|4[1-7])|3(?:3[1-389]|4[1-7])|4[34][12])\\d{4}","\\d{10}",null,null,"6492311234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002345678"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002345678"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"64971[01]\\d{4}","\\d{10}",null,null,"6497101234"],"TC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"649",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"9(?:11|99)","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"TD":[null,[null,null,"[2679]\\d{7}","\\d{8}"],[null,null,"22(?:[3789]0|5[0-5]|6[89])\\d{4}","\\d{8}",null,null,"22501234"],[null,null,"(?:6[02368]\\d|77\\d|9(?:5[0-4]|9\\d))\\d{5}","\\d{8}",null,null,"63012345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TD",235,"00|16",null,null,null,null,null,"00",null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[78]","\\d{2}",null,null,"17"],[null,null,"NA","NA"]],"TG":[null,[null,null,"[29]\\d{7}","\\d{8}"],[null,null,"2(?:2[2-7]|3[23]|44|55|66|77)\\d{5}","\\d{8}",null,null,"22212345"],[null,null,"9[0-289]\\d{6}","\\d{8}",null,null,"90112345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TG",228,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:01|1[78]|7[17])","\\d{3}",null,null,"117"],[null,null,"NA","NA"]],"TH":[null,[null,null,"[2-9]\\d{7,8}|1\\d{3}(?:\\d{6})?","\\d{4}|\\d{8,10}"],[null,null,"(?:2[1-9]|3[2-9]|4[2-5]|5[2-6]|7[3-7])\\d{6}","\\d{8}",null,null,"21234567"],[null,null,"[89]\\d{8}","\\d{9}",null,null,"812345678"],[null,null,"1800\\d{6}","\\d{10}",null,null,"1800123456"],[null,null,"1900\\d{6}","\\d{10}",null,null,"1900123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"60\\d{7}","\\d{9}",null,null,"601234567"],"TH",66,"00","0",null,null,"0",null,null,null,[[null,"(2)(\\d{3})(\\d{4})","$1 $2 $3",["2"],"0$1","",0],[null,"([3-9]\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[3-9]"],"0$1","",0],[null,"(1[89]00)(\\d{3})(\\d{3})","$1 $2 $3",["1"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"1\\d{3}","\\d{4}",null,null,"1100"],[null,null,"1\\d{3}","\\d{4}",null,null,"1100"],null,[null,null,"1(?:669|9[19])","\\d{3,4}",null,null,"191"],[null,null,"NA","NA"]],"TJ":[null,[null,null,"[3-59]\\d{8}","\\d{3,9}"],[null,null,"(?:3(?:1[3-5]|2[245]|3[12]|4[24-7]|5[25]|72)|4(?:46|74|87))\\d{6}","\\d{3,9}",null,null,"372123456"],[null,null,"(?:50[15]|9[0-35-9]\\d)\\d{6}","\\d{9}",null,null,"917123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TJ",992,"810","8",null,null,"8",null,"8~10",null,[[null,"([349]\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[34]7|91[78]"],"(8) $1","",1],[null,"([459]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["4[48]|5|9(?:1[59]|[0235-9])"],"(8) $1","",1],[null,"(331700)(\\d)(\\d{2})","$1 $2 $3",["331","3317","33170","331700"],"(8) $1","",1],[null,"(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["3[1-5]","3(?:[1245]|3(?:[02-9]|1[0-589]))"],"(8) $1","",1]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:0[1-3]|12)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"TK":[null,[null,null,"[2-9]\\d{3}","\\d{4}"],[null,null,"[2-4]\\d{3}","\\d{4}",null,null,"3010"],[null,null,"[5-9]\\d{3}","\\d{4}",null,null,"5190"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TK",690,"00",null,null,null,null,null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"TL":[null,[null,null,"[2-489]\\d{6}|7\\d{6,7}","\\d{7,8}"],[null,null,"(?:2[1-5]|3[1-9]|4[1-4])\\d{5}","\\d{7}",null,null,"2112345"],[null,null,"7[3-8]\\d{6}","\\d{8}",null,null,"77212345"],[null,null,"80\\d{5}","\\d{7}",null,null,"8012345"],[null,null,"90\\d{5}","\\d{7}",null,null,"9012345"],[null,null,"NA","NA"],[null,null,"70\\d{5}","\\d{7}",null,null,"7012345"],[null,null,"NA","NA"],"TL",670,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",["[2-489]"],"","",0],[null,"(\\d{4})(\\d{4})","$1 $2",["7"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[25]","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"TM":[null,[null,null,"[1-6]\\d{7}","\\d{8}"],[null,null,"(?:1(?:2\\d|3[1-9])|2(?:22|4[0-35-8])|3(?:22|4[03-9])|4(?:22|3[128]|4\\d|6[15])|5(?:22|5[7-9]|6[014-689]))\\d{5}","\\d{8}",null,null,"12345678"],[null,null,"6[3-8]\\d{6}","\\d{8}",null,null,"66123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TM",993,"810","8",null,null,"8",null,"8~10",null,[[null,"(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2-$3-$4",["12"],"(8 $1)","",0],[null,"(\\d{2})(\\d{6})","$1 $2",["6"],"8 $1","",0],[null,"(\\d{3})(\\d)(\\d{2})(\\d{2})","$1 $2-$3-$4",["13|[2-5]"],"(8 $1)","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"0[1-3]","\\d{2}",null,null,"03"],[null,null,"NA","NA"]],"TN":[null,[null,null,"[2-57-9]\\d{7}","\\d{8}"],[null,null,"(?:3[012]|7\\d|81)\\d{6}","\\d{8}",null,null,"71234567"],[null,null,"(?:[259]\\d|4[0-2])\\d{6}","\\d{8}",null,null,"20123456"],[null,null,"NA","NA"],[null,null,"8[028]\\d{6}","\\d{8}",null,null,"80123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TN",216,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"19[078]","\\d{3}",null,null,"197"],[null,null,"NA","NA"]],"TO":[null,[null,null,"[02-8]\\d{4,6}","\\d{5,7}"],[null,null,"(?:2\\d|3[1-8]|4[1-4]|[56]0|7[0149]|8[05])\\d{3}","\\d{5}",null,null,"20123"],[null,null,"(?:7[578]|8[7-9])\\d{5}","\\d{7}",null,null,"7715123"],[null,null,"0800\\d{3}","\\d{7}",null,null,"0800222"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TO",676,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{3})","$1-$2",["[1-6]|7[0-4]|8[05]"],"","",0],[null,"(\\d{3})(\\d{4})","$1 $2",["7[5-9]|8[7-9]"],"","",0],[null,"(\\d{4})(\\d{3})","$1 $2",["0"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"9(?:11|22|33|99)","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"TR":[null,[null,null,"[2-589]\\d{9}|444\\d{4}","\\d{7,10}"],[null,null,"(?:2(?:[13][26]|[28][2468]|[45][268]|[67][246])|3(?:[13][28]|[24-6][2468]|[78][02468]|92)|4(?:[16][246]|[23578][2468]|4[26]))\\d{7}","\\d{10}",null,null,"2123456789"],[null,null,"5(?:0[1-7]|22|[34]\\d|5[1-59]|9[246])\\d{7}","\\d{10}",null,null,"5012345678"],[null,null,"800\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"900\\d{7}","\\d{10}",null,null,"9001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TR",90,"00","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[23]|4(?:[0-35-9]|4[0-35-9])"],"(0$1)","",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[589]"],"0$1","",1],[null,"(444)(\\d{1})(\\d{3})","$1 $2 $3",["444"],"","",0]],null,[null,null,"512\\d{7}","\\d{10}",null,null,"5123456789"],null,null,[null,null,"444\\d{4}","\\d{7}",null,null,"4441444"],[null,null,"444\\d{4}|850\\d{7}","\\d{7,10}",null,null,"4441444"],null,[null,null,"1(?:1[02]|55)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"TT":[null,[null,null,"[589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"868(?:2(?:01|2[1-5])|6(?:07|1[4-6]|2[1-9]|[3-6]\\d|7[0-79]|9[0-8])|82[12])\\d{4}","\\d{7}(?:\\d{3})?",null,null,"8682211234"],[null,null,"868(?:2(?:8[59]|9\\d)|3(?:0[1-9]|1[02-9]|[2-9]\\d)|4[6-9]\\d|6(?:20|78|8\\d)|7(?:1[02-9]|[02-9]\\d))\\d{4}","\\d{10}",null,null,"8682911234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002345678"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002345678"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"TT",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"868",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"99[09]","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"TV":[null,[null,null,"[29]\\d{4,5}","\\d{5,6}"],[null,null,"2[02-9]\\d{3}","\\d{5}",null,null,"20123"],[null,null,"90\\d{4}","\\d{6}",null,null,"901234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TV",688,"00",null,null,null,null,null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"TW":[null,[null,null,"[2-9]\\d{7,8}","\\d{8,9}"],[null,null,"[2-8]\\d{7,8}","\\d{8,9}",null,null,"21234567"],[null,null,"9\\d{8}","\\d{9}",null,null,"912345678"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"900\\d{6}","\\d{9}",null,null,"900123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"TW",886,"0(?:0[25679]|19)","0","#",null,"0",null,null,null,[[null,"([2-8])(\\d{3,4})(\\d{4})","$1 $2 $3",["[2-7]|8[1-9]"],"0$1","",0],[null,"([89]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["80|9"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[029]","\\d{3}",null,null,"110"],[null,null,"NA","NA"]],"TZ":[null,[null,null,"\\d{9}","\\d{7,9}"],[null,null,"2[2-8]\\d{7}","\\d{7,9}",null,null,"222345678"],[null,null,"(?:6[158]|7[1-9])\\d{7}","\\d{9}",null,null,"612345678"],[null,null,"80[08]\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"90\\d{7}","\\d{9}",null,null,"900123456"],[null,null,"8(?:40|6[01])\\d{6}","\\d{9}",null,null,"840123456"],[null,null,"NA","NA"],[null,null,"41\\d{7}","\\d{9}",null,null,"412345678"],"TZ",255,"00[056]","0",null,null,"0",null,null,null,[[null,"([24]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[24]"],"0$1","",0],[null,"([67]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["[67]"],"0$1","",0],[null,"([89]\\d{2})(\\d{2})(\\d{4})","$1 $2 $3",["[89]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"11[12]|999","\\d{3}",null,null,"111"],[null,null,"NA","NA"]],"UA":[null,[null,null,"[3-689]\\d{8}","\\d{5,9}"],[null,null,"(?:3[1-8]|4[13-8]|5[1-7]|6[12459])\\d{7}","\\d{5,9}",null,null,"311234567"],[null,null,"(?:39|50|6[36-8]|9[1-9])\\d{7}","\\d{9}",null,null,"391234567"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"900\\d{6}","\\d{9}",null,null,"900123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"89\\d{7}","\\d{9}",null,null,"891234567"],"UA",380,"00","0",null,null,"0",null,"0~0",null,[[null,"([3-689]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["[38]9|4(?:[45][0-5]|87)|5(?:0|6[37]|7[37])|6[36-8]|9[1-9]","[38]9|4(?:[45][0-5]|87)|5(?:0|6(?:3[14-7]|7)|7[37])|6[36-8]|9[1-9]"],"0$1","",0],[null,"([3-689]\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["3[1-8]2|4[13678]2|5(?:[12457]2|6[24])|6(?:[49]2|[12][29]|5[24])|8[0-8]|90","3(?:[1-46-8]2[013-9]|52)|4(?:[1378]2|62[013-9])|5(?:[12457]2|6[24])|6(?:[49]2|[12][29]|5[24])|8[0-8]|90"],"0$1","",0],[null,"([3-6]\\d{3})(\\d{5})","$1 $2",["3(?:5[013-9]|[1-46-8])|4(?:[137][013-9]|6|[45][6-9]|8[4-6])|5(?:[1245][013-9]|6[0135-9]|3|7[4-6])|6(?:[49][013-9]|5[0135-9]|[12][13-8])","3(?:5[013-9]|[1-46-8](?:22|[013-9]))|4(?:[137][013-9]|6(?:[013-9]|22)|[45][6-9]|8[4-6])|5(?:[1245][013-9]|6(?:3[02389]|[015689])|3|7[4-6])|6(?:[49][013-9]|5[0135-9]|[12][13-8])"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:0[123]|12)","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"UG":[null,[null,null,"\\d{9}","\\d{5,9}"],[null,null,"20(?:[0147]\\d{2}|2(?:40|[5-9]\\d)|3[23]\\d|5[0-4]\\d|60\\d|8[0-2]\\d)\\d{4}|[34]\\d{8}","\\d{5,9}",null,null,"312345678"],[null,null,"7(?:0[0-7]|[15789]\\d|[23]0|[46][0-4])\\d{6}","\\d{9}",null,null,"712345678"],[null,null,"800[123]\\d{5}","\\d{9}",null,null,"800123456"],[null,null,"90[123]\\d{6}","\\d{9}",null,null,"901123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"UG",256,"00[057]","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{6})","$1 $2",["[7-9]|20(?:[013-8]|2[5-9])|4(?:6[45]|[7-9])"],"0$1","",0],[null,"(\\d{2})(\\d{7})","$1 $2",["3|4(?:[1-5]|6[0-36-9])"],"0$1","",0],[null,"(2024)(\\d{5})","$1 $2",["2024"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"999","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"US":[null,[null,null,"[2-9]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[4589]|3[149]|4[08]|5[1-46]|6[0279]|7[06]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[014679]|47|5[12]|6[01]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|69|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-37]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[036]|3[016]|4[16]|5[017]|6[0-279]|78|8[12])|7(?:0[1-46-8]|1[02-9]|2[047]|3[124]|4[07]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|28|3[0-25]|4[3578]|5[06-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[1678]|4[0179]|5[1246]|7[0-3589]|8[0459]))[2-9]\\d{6}","\\d{7}(?:\\d{3})?",null,null,"2015555555"],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[4589]|3[149]|4[08]|5[1-46]|6[0279]|7[06]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[014679]|47|5[12]|6[01]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|69|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-37]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[036]|3[016]|4[16]|5[017]|6[0-279]|78|8[12])|7(?:0[1-46-8]|1[02-9]|2[047]|3[124]|4[07]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|28|3[0-25]|4[3578]|5[06-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[1678]|4[0179]|5[1246]|7[0-3589]|8[0459]))[2-9]\\d{6}","\\d{7}(?:\\d{3})?",null,null,"2015555555"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002345678"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002345678"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"US",1,"011","1",null,null,"1",null,null,1,[[null,"(\\d{3})(\\d{4})","$1-$2",null,"","",1],[null,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",null,"","",1]],[[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3"]],[null,null,"NA","NA"],1,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"112|911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"UY":[null,[null,null,"[2489]\\d{6,7}","\\d{7,8}"],[null,null,"2\\d{7}|4[2-7]\\d{6}","\\d{7,8}",null,null,"21231234"],[null,null,"9[13-9]\\d{6}","\\d{8}",null,null,"94231234"],[null,null,"80[05]\\d{4}","\\d{7}",null,null,"8001234"],[null,null,"90[0-8]\\d{4}","\\d{7}",null,null,"9001234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"UY",598,"0(?:1[3-9]\\d|0)","0"," int. ",null,"0",null,"00",null,[[null,"(\\d{4})(\\d{4})","$1 $2",["[24]"],"","",0],[null,"(\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["9[1-9]"],"0$1","",0],[null,"(\\d{3})(\\d{4})","$1 $2",["[89]0"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"128|911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"UZ":[null,[null,null,"[679]\\d{8}","\\d{7,9}"],[null,null,"(?:6(?:1(?:22|3[124]|4[1-4]|5[123578]|64)|2(?:22|3[0-57-9]|41)|5(?:22|3[3-7]|5[024-8])|6\\d{2}|7(?:[23]\\d|7[69])|9(?:22|4[1-8]|6[135]))|7(?:0(?:5[4-9]|6[0146]|7[12456]|9[135-8])|1[12]\\d|2(?:22|3[1345789]|4[123579]|5[14])|3(?:2\\d|3[1578]|4[1-35-7]|5[1-57]|61)|4(?:2\\d|3[1-579]|7[1-79])|5(?:22|5[1-9]|6[1457])|6(?:22|3[12457]|4[13-8])|9(?:22|5[1-9])))\\d{5}","\\d{7,9}",null,null,"662345678"],[null,null,"6(?:1(?:2(?:98|2[01])|35[0-4]|50\\d|61[23]|7(?:[01][017]|4\\d|55|9[5-9]))|2(?:11\\d|2(?:[12]1|9[01379])|5(?:[126]\\d|3[0-4])|7\\d{2})|5(?:19[01]|2(?:27|9[26])|30\\d|59\\d|7\\d{2})|6(?:2(?:1[5-9]|2[0367]|38|41|52|60)|3[79]\\d|4(?:56|83)|7(?:[07]\\d|1[017]|3[07]|4[047]|5[057]|67|8[0178]|9[79])|9[0-3]\\d)|7(?:2(?:24|3[237]|4[5-9]|7[15-8])|5(?:7[12]|8[0589])|7(?:0\\d|[39][07])|9(?:0\\d|7[079]))|9(2(?:1[1267]|5\\d|3[01]|7[0-4])|5[67]\\d|6(?:2[0-26]|8\\d)|7\\d{2}))\\d{4}|7(?:0\\d{3}|1(?:13[01]|6(?:0[47]|1[67]|66)|71[3-69]|98\\d)|2(?:2(?:2[79]|95)|3(?:2[5-9]|6[0-6])|57\\d|7(?:0\\d|1[17]|2[27]|3[37]|44|5[057]|66|88))|3(?:2(?:1[0-6]|21|3[469]|7[159])|33\\d|5(?:0[0-4]|5[579]|9\\d)|7(?:[0-3579]\\d|4[0467]|6[67]|8[078])|9[4-6]\\d)|4(?:2(?:29|5[0257]|6[0-7]|7[1-57])|5(?:1[0-4]|8\\d|9[5-9])|7(?:0\\d|1[024589]|2[0127]|3[0137]|[46][07]|5[01]|7[5-9]|9[079])|9(?:7[015-9]|[89]\\d))|5(?:112|2(?:0\\d|2[29]|[49]4)|3[1568]\\d|52[6-9]|7(?:0[01578]|1[017]|[23]7|4[047]|[5-7]\\d|8[78]|9[079]))|6(?:2(?:2[1245]|4[2-4])|39\\d|41[179]|5(?:[349]\\d|5[0-2])|7(?:0[017]|[13]\\d|22|44|55|67|88))|9(?:22[128]|3(?:2[0-4]|7\\d)|57[05629]|7(?:2[05-9]|3[37]|4\\d|60|7[2579]|87|9[07])))\\d{4}|9[0-57-9]\\d{7}","\\d{7,9}",null,null,"912345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"UZ",998,"810","8",null,null,"8",null,"8~10",null,[[null,"([679]\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"8 $1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"0(?:0[123]|[123]|50)","\\d{2,3}",null,null,"01"],[null,null,"NA","NA"]],"VA":[null,[null,null,"06\\d{8}","\\d{10}"],[null,null,"06698\\d{5}","\\d{10}",null,null,"0669812345"],[null,null,"N/A","N/A"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"VA",379,"00",null,null,null,null,null,null,null,[[null,"(06)(\\d{4})(\\d{4})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"11[2358]","\\d{3}",null,null,"113"],[null,null,"NA","NA"]],"VC":[null,[null,null,"[5789]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"784(?:266|3(?:6[6-9]|7\\d|8[0-24-6])|4(?:38|5[0-36-8]|8\\d|9[01])|555|638|784)\\d{4}","\\d{7}(?:\\d{3})?",null,null,"7842661234"],[null,null,"784(?:4(?:3[0-4]|5[45]|9[2-5])|5(?:2[6-9]|3[0-4]|93))\\d{4}","\\d{10}",null,null,"7844301234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002345678"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002345678"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"VC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"784",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"9(?:11|99)","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"VE":[null,[null,null,"[24589]\\d{9}","\\d{7,10}"],[null,null,"(?:2(?:12|3[457-9]|[58][1-9]|[467]\\d|9[1-6])|50[01])\\d{7}","\\d{7,10}",null,null,"2121234567"],[null,null,"4(?:1[24-8]|2[46])\\d{7}","\\d{10}",null,null,"4121234567"],[null,null,"800\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"900\\d{7}","\\d{10}",null,null,"9001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"VE",58,"00","0",null,null,"(1\\d{2})|0",null,null,null,[[null,"(\\d{3})(\\d{7})","$1-$2",null,"0$1","$CC $1",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"171","\\d{3}",null,null,"171"],[null,null,"NA","NA"]],"VG":[null,[null,null,"[2589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"284(?:(?:229|4(?:22|9[45])|774|8(?:52|6[459]))\\d{4}|496[0-5]\\d{3})","\\d{7}(?:\\d{3})?",null,null,"2842291234"],[null,null,"284(?:(?:3(?:0[0-3]|4[0-367])|4(?:4[0-6]|68|99)|54[0-57])\\d{4}|496[6-9]\\d{3})","\\d{10}",null,null,"2843001234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002345678"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002345678"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"VG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,"284",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"9(?:11|99)","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"VI":[null,[null,null,"[3589]\\d{9}","\\d{7}(?:\\d{3})?"],[null,null,"340(?:2(?:01|2[067]|36|44|77)|3(?:32|44)|4(?:4[38]|7[34])|5(?:1[34]|55)|6(?:26|4[23]|9[023])|7(?:[17]\\d|27)|884|998)\\d{4}","\\d{7}(?:\\d{3})?",null,null,"3406421234"],[null,null,"340(?:2(?:01|2[067]|36|44|77)|3(?:32|44)|4(?:4[38]|7[34])|5(?:1[34]|55)|6(?:26|4[23]|9[023])|7(?:[17]\\d|27)|884|998)\\d{4}","\\d{7}(?:\\d{3})?",null,null,"3406421234"],[null,null,"8(?:00|55|66|77|88)[2-9]\\d{6}","\\d{10}",null,null,"8002345678"],[null,null,"900[2-9]\\d{6}","\\d{10}",null,null,"9002345678"],[null,null,"NA","NA"],[null,null,"5(?:00|33|44)[2-9]\\d{6}","\\d{10}",null,null,"5002345678"],[null,null,"NA","NA"],"VI",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,"NA","NA"],null,"340",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"VN":[null,[null,null,"[17]\\d{6,9}|[2-69]\\d{7,9}|8\\d{6,8}","\\d{7,10}"],[null,null,"(?:2(?:[025-79]|1[0189]|[348][01])|3(?:[0136-9]|[25][01])|4\\d|5(?:[01][01]|[2-9])|6(?:[0-46-8]|5[01])|7(?:[02-79]|[18][01])|8[1-9])\\d{7}","\\d{9,10}",null,null,"2101234567"],[null,null,"(?:9\\d|1(?:2\\d|6[2-9]|8[68]|99))\\d{7}","\\d{9,10}",null,null,"912345678"],[null,null,"1800\\d{4,6}","\\d{8,10}",null,null,"1800123456"],[null,null,"1900\\d{4,6}","\\d{8,10}",null,null,"1900123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"VN",84,"00","0",null,null,"0",null,null,null,[[null,"([17]99)(\\d{4})","$1 $2",["[17]99"],"0$1","",1],[null,"([48])(\\d{4})(\\d{4})","$1 $2 $3",["[48]"],"0$1","",1],[null,"([235-7]\\d)(\\d{4})(\\d{3})","$1 $2 $3",["2[025-79]|3[0136-9]|5[2-9]|6[0-46-8]|7[02-79]"],"0$1","",1],[null,"(80)(\\d{5})","$1 $2",["80"],"0$1","",1],[null,"(69\\d)(\\d{4,5})","$1 $2",["69"],"0$1","",1],[null,"([235-7]\\d{2})(\\d{4})(\\d{3})","$1 $2 $3",["2[1348]|3[25]|5[01]|65|7[18]"],"0$1","",1],[null,"(9\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["9"],"0$1","",1],[null,"(1[2689]\\d)(\\d{3})(\\d{4})","$1 $2 $3",["1(?:[26]|8[68]|99)"],"0$1","",1],[null,"(1[89]00)(\\d{4,6})","$1 $2",["1[89]0"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"[17]99\\d{4}|69\\d{5,6}","\\d{7,8}",null,null,"1992000"],[null,null,"[17]99\\d{4}|69\\d{5,6}|80\\d{5}","\\d{7,8}",null,null,"1992000"],null,[null,null,"11[345]","\\d{3}",null,null,"113"],[null,null,"NA","NA"]],"VU":[null,[null,null,"[2-57-9]\\d{4,6}","\\d{5,7}"],[null,null,"(?:2[2-9]\\d|3(?:[5-7]\\d|8[0-8])|48[4-9]|88\\d)\\d{2}","\\d{5}",null,null,"22123"],[null,null,"(?:5(?:7[2-5]|[3-69]\\d)|7[013-7]\\d)\\d{4}","\\d{7}",null,null,"5912345"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"VU",678,"00",null,null,null,null,null,null,null,[[null,"(\\d{3})(\\d{4})","$1 $2",["[579]"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"3[03]\\d{3}|900\\d{4}","\\d{5,7}",null,null,"30123"],null,[null,null,"112","\\d{3}",null,null,"112"],[null,null,"NA","NA"]],"WF":[null,[null,null,"[5-7]\\d{5}","\\d{6}"],[null,null,"(?:50|68|72)\\d{4}","\\d{6}",null,null,"501234"],[null,null,"(?:50|68|72)\\d{4}","\\d{6}",null,null,"501234"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"WF",681,"00",null,null,null,null,null,null,1,[[null,"(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1[578]","\\d{2}",null,null,"15"],[null,null,"NA","NA"]],"WS":[null,[null,null,"[2-8]\\d{4,6}","\\d{5,7}"],[null,null,"(?:[2-5]\\d|6[1-9]|84\\d{2})\\d{3}","\\d{5,7}",null,null,"22123"],[null,null,"(?:60|7[25-7]\\d)\\d{4}","\\d{6,7}",null,null,"601234"],[null,null,"800\\d{3}","\\d{6}",null,null,"800123"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"WS",685,"0",null,null,null,null,null,null,null,[[null,"(8\\d{2})(\\d{3,4})","$1 $2",["8"],"","",0],[null,"(7\\d)(\\d{5})","$1 $2",["7"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"99[4-6]","\\d{3}",null,null,"994"],[null,null,"NA","NA"]],"YE":[null,[null,null,"[1-7]\\d{6,8}","\\d{6,9}"],[null,null,"(?:1(?:7\\d|[2-68])|2[2-68]|3[2358]|4[2-58]|5[2-6]|6[3-58]|7[24-68])\\d{5}","\\d{6,8}",null,null,"1234567"],[null,null,"7[0137]\\d{7}","\\d{9}",null,null,"712345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"YE",967,"00","0",null,null,"0",null,null,null,[[null,"([1-7])(\\d{3})(\\d{3,4})","$1 $2 $3",["[1-6]|7[24-68]"],"0$1","",0],[null,"(7\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["7[0137]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"19[1459]","\\d{3}",null,null,"191"],[null,null,"NA","NA"]],"YT":[null,[null,null,"[268]\\d{8}","\\d{9}"],[null,null,"2696[0-4]\\d{4}","\\d{9}",null,null,"269601234"],[null,null,"639\\d{6}","\\d{9}",null,null,"639123456"],[null,null,"80\\d{7}","\\d{9}",null,null,"801234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"YT",262,"00","0",null,null,"0",null,null,null,null,null,[null,null,"NA","NA"],null,"269|63",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"1(?:12|5)","\\d{2,3}",null,null,"15"],[null,null,"NA","NA"]],"ZA":[null,[null,null,"[1-79]\\d{8}|8(?:[067]\\d{7}|[1-4]\\d{3,7})","\\d{5,9}"],[null,null,"(?:1[0-8]|2[0-378]|3[1-69]|4\\d|5[1346-8])\\d{7}","\\d{9}",null,null,"101234567"],[null,null,"(?:6[0-5]|7[0-46-9])\\d{7}|8[1-4]\\d{3,7}","\\d{5,9}",null,null,"711234567"],[null,null,"80\\d{7}","\\d{9}",null,null,"801234567"],[null,null,"86[2-9]\\d{6}|90\\d{7}","\\d{9}",null,null,"862345678"],[null,null,"860\\d{6}","\\d{9}",null,null,"860123456"],[null,null,"NA","NA"],[null,null,"87\\d{7}","\\d{9}",null,null,"871234567"],"ZA",27,"00","0",null,null,"0",null,null,null,[[null,"(860)(\\d{3})(\\d{3})","$1 $2 $3",["860"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["[1-79]|8(?:[0-47]|6[1-9])"],"0$1","",0],[null,"(\\d{2})(\\d{3,4})","$1 $2",["8[1-4]"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{2,3})","$1 $2 $3",["8[1-4]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"861\\d{6}","\\d{9}",null,null,"861123456"],null,[null,null,"1(?:01(?:11|77)|12)","\\d{3,5}",null,null,"10111"],[null,null,"NA","NA"]],"ZM":[null,[null,null,"[289]\\d{8}","\\d{9}"],[null,null,"21[1-8]\\d{6}","\\d{9}",null,null,"211234567"],[null,null,"9(?:5[05]|6\\d|7[13-9])\\d{6}","\\d{9}",null,null,"955123456"],[null,null,"800\\d{6}","\\d{9}",null,null,"800123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"ZM",260,"00","0",null,null,"0",null,null,null,[[null,"([29]\\d)(\\d{7})","$1 $2",["[29]"],"0$1","",0],[null,"(800)(\\d{3})(\\d{3})","$1 $2 $3",["8"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"(?:112|99[139])","\\d{3}",null,null,"999"],[null,null,"NA","NA"]],"ZW":[null,[null,null,"2(?:[012457-9]\\d{3,8}|6\\d{3,6})|[13-79]\\d{4,8}|8[06]\\d{8}","\\d{3,10}"],[null,null,"(?:1[3-9]|2(?:0[45]|[16]|2[28]|[49]8?|58[23]|7[246]|8[1346-9])|3(?:08?|17?|3[78]|[2456]|7[1569]|8[379])|5(?:[07-9]|1[78]|483|5(?:7?|8))|6(?:0|28|37?|[45][68][78]|98?)|848)\\d{3,6}|(?:2(?:27|5|7[135789]|8[25])|3[39]|5[1-46]|6[126-8])\\d{4,6}|2(?:(?:0|70)\\d{5,6}|2[05]\\d{7})|(?:4\\d|9[2-8])\\d{4,7}","\\d{3,10}",null,null,"1312345"],[null,null,"7[1378]\\d{7}|86(?:22|44)\\d{6}","\\d{9,10}",null,null,"711234567"],[null,null,"800\\d{7}","\\d{10}",null,null,"8001234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"86(?:1[12]|30|55|77|8[367]|99)\\d{6}","\\d{10}",null,null,"8686123456"],"ZW",263,"00","0",null,null,"0",null,null,null,[[null,"([49])(\\d{3})(\\d{2,5})","$1 $2 $3",["4|9[2-9]"],"0$1","",0],[null,"([179]\\d)(\\d{3})(\\d{3,4})","$1 $2 $3",["[19]1|7"],"0$1","",0],[null,"(86\\d{2})(\\d{3})(\\d{3})","$1 $2 $3",["86[24]"],"0$1","",0],[null,"([2356]\\d{2})(\\d{3,5})","$1 $2",["2(?:[278]|0[45]|[49]8)|3(?:08|17|3[78]|[78])|5[15][78]|6(?:[29]8|37|[68][78])"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["2(?:[278]|0[45]|48)|3(?:08|17|3[78]|[78])|5[15][78]|6(?:[29]8|37|[68][78])|80"],"0$1","",0],[null,"([1-356]\\d)(\\d{3,5})","$1 $2",["1[3-9]|2(?:[1-469]|0[0-35-9]|[45][0-79])|3(?:0[0-79]|1[0-689]|[24-69]|3[0-69])|5(?:[02-46-9]|[15][0-69])|6(?:[0145]|[29][0-79]|3[0-689]|[68][0-69])"],"0$1","",0],[null,"([1-356]\\d)(\\d{3})(\\d{3})","$1 $2 $3",["1[3-9]|2(?:[1-469]|0[0-35-9]|[45][0-79])|3(?:0[0-79]|1[0-689]|[24-69]|3[0-69])|5(?:[02-46-9]|[15][0-69])|6(?:[0145]|[29][0-79]|3[0-689]|[68][0-69])"],"0$1","",0],[null,"([25]\\d{3})(\\d{3,5})","$1 $2",["(?:25|54)8","258[23]|5483"],"0$1","",0],[null,"([25]\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["(?:25|54)8","258[23]|5483"],"0$1","",0],[null,"(8\\d{3})(\\d{6})","$1 $2",["86"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"(?:112|99[3459])","\\d{3}",null,null,"999"],[null,null,"NA","NA"]]}}
\ No newline at end of file
diff --git a/libPhoneNumber/PhoneNumberMetaDataForTesting.json b/libPhoneNumber/PhoneNumberMetaDataForTesting.json
new file mode 100644
index 0000000..50ca08b
--- /dev/null
+++ b/libPhoneNumber/PhoneNumberMetaDataForTesting.json
@@ -0,0 +1 @@
+{"countryCodeToRegionCodeMap":{"1":["US","BS"],"39":["IT"],"44":["GB"],"48":["PL"],"49":["DE"],"52":["MX"],"54":["AR"],"55":["BR"],"61":["AU"],"64":["NZ"],"65":["SG"],"81":["JP"],"82":["KR"],"244":["AO"],"262":["RE","YT"],"375":["BY"],"376":["AD"],"800":["001"],"971":["AE"],"979":["001"]},"countryToMetadata":{"800":[null,[null,null,"\\d{8}","\\d{8}",null,null,"12345678"],[null,null,"NA","NA",null,null,"12345678"],[null,null,"NA","NA",null,null,"12345678"],[null,null,"\\d{8}","\\d{8}",null,null,"12345678"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"001",800,"",null,null,null,null,null,null,1,[[null,"(\\d{4})(\\d{4})","$1 $2",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"NA","NA"],[null,null,"NA","NA"]],"979":[null,[null,null,"\\d{9}","\\d{9}",null,null,"123456789"],[null,null,"NA","NA",null,null,"123456789"],[null,null,"NA","NA",null,null,"123456789"],[null,null,"NA","NA"],[null,null,"\\d{9}","\\d{9}",null,null,"123456789"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"001",979,"",null,null,null,null,null,null,1,[[null,"(\\d)(\\d{4})(\\d{4})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"AD":[null,[],[],[],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AD",376,"00",null,null,null,null,null,null,1,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"AE":[null,[null,null,"[1-9]\\d{8}","\\d{9}"],[null,null,"[1-9]\\d{8}","\\d{9}"],[null,null,"[1-9]\\d{8}","\\d{9}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AE",971,"00",null,null,null,null,null,null,1,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"600\\d{6}","\\d{9}",null,null,"600123456"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"AO":[null,[null,null,"[29]\\d{8}","\\d{9}"],[null,null,"2\\d(?:[26-9]\\d|\\d[26-9])\\d{5}","\\d{9}",null,null,"222123456"],[null,null,"9[1-3]\\d{7}","\\d{9}",null,null,"923123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AO",244,"00","0~0",null,null,"0~0",null,null,null,[[null,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",null,"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"AR":[null,[null,null,"[1-3689]\\d{9,10}","\\d{6,11}"],[null,null,"[1-3]\\d{9}","\\d{6,10}"],[null,null,"9\\d{10}|[1-3]\\d{9}","\\d{10,11}"],[null,null,"80\\d{8}","\\d{10}"],[null,null,"6(0\\d|10)\\d{7}","\\d{10}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AR",54,"00","0",null,null,"0(?:(11|343|3715)15)?","9$1",null,null,[[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["11"],"0$1","",0],[null,"(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["1[02-9]|[23]"],"0$1","",0],[null,"(9)(11)(\\d{4})(\\d{4})","$2 15 $3-$4",["911"],"0$1","",0],[null,"(9)(\\d{4})(\\d{2})(\\d{4})","$2 $3-$4",["9(?:1[02-9]|[23])"],"0$1","0$1 $CC",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]"],"0$1","",0]],[[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2-$3",["11","11"],"0$1","",0],[null,"(\\d{4})(\\d{2})(\\d{4})","$1 $2-$3",["1[02-9]|[23]","1[02-9]|[23]"],"0$1","",0],[null,"(9)(11)(\\d{4})(\\d{4})","$1 $2 $3 $4",["911"]],[null,"(9)(\\d{4})(\\d{2})(\\d{4})","$1 $2 $3 $4",["9(?:1[02-9]|[23])"]],[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[68]","[68]"],"0$1","",0]],[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"AU":[null,[null,null,"[1-578]\\d{4,14}","\\d{5,15}"],[null,null,"[2378]\\d{8}","\\d{9}"],[null,null,"4\\d{8}","\\d{9}"],[null,null,"1800\\d{6}","\\d{10}"],[null,null,"190[0126]\\d{6}","\\d{10}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"AU",61,"001[12]","0",null,null,"0",null,"0011",null,[[null,"(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["1"],"$1","",0],[null,"(\\d{1})(\\d{4})(\\d{4})","$1 $2 $3",["[2-478]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"BR":[null,[],[],[],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BR",55,"0014","0",null,null,"0",null,null,1,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"19[023]|911","\\d{3}",null,null,"190"],[null,null,"NA","NA"]],"BS":[null,[null,null,"(242|8(00|66|77|88)|900)\\d{7}","\\d{7,10}"],[null,null,"242(?:3(?:02|[236][1-9]|4[0-24-9]|5[0-68]|7[3-57]|9[2-5])|4(?:2[237]|51|64|77)|502|636|702)\\d{4}","\\d{7,10}"],[null,null,"242(357|359|457|557)\\d{4}","\\d{10}"],[null,null,"8(00|66|77|88)\\d{7}","\\d{10}"],[null,null,"900\\d{7}","\\d{10}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"BY":[null,[null,null,"[1-9]\\d{5}","\\d{6}"],[null,null,"[1-9]\\d{5}","\\d{6}",null,null,"112345"],[null,null,"[1-9]\\d{5}","\\d{6}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"BY",375,"810","8",null,null,"80?|99999",null,null,1,[[null,"(\\d{4})","$1",["[1-8]"],"8 $1","",0],[null,"(\\d{2})(\\d{3})","$1 $2",["[1-8]"],"8$1","",0],[null,"(\\d{3})(\\d{3})","$1 $2",["[1-8]"],"8 $1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"DE":[null,[null,null,"\\d{4,14}","\\d{2,14}"],[null,null,"(?:[24-6]\\d{2}|3[03-9]\\d|[789](?:[1-9]\\d|0[2-9]))\\d{1,8}","\\d{2,14}",null,null,"30123456"],[null,null,"1(5\\d{9}|7\\d{8}|6[02]\\d{8}|63\\d{7})","\\d{10,11}"],[null,null,"800\\d{7}","\\d{10}"],[null,null,"900([135]\\d{6}|9\\d{7})","\\d{10,11}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"DE",49,"00","0",null,null,"0",null,null,null,[[null,"(\\d{3})(\\d{3,8})","$1 $2",["2|3[3-9]|906|[4-9][1-9]1"],"0$1","",0],[null,"(\\d{2})(\\d{4,11})","$1/$2",["[34]0|[68]9"],"0$1","",0],[null,"([4-9]\\d)(\\d{2})","$1 $2",["[4-9]","[4-6]|[7-9](?:\\d[1-9]|[1-9]\\d)"],"0$1","",0],[null,"([4-9]\\d{3})(\\d{2,7})","$1 $2",["[4-9]","[4-6]|[7-9](?:\\d[1-9]|[1-9]\\d)"],"0$1","",0],[null,"(\\d{3})(\\d{1})(\\d{6})","$1 $2 $3",["800"],"0$1","",0],[null,"(\\d{3})(\\d{3,4})(\\d{4})","$1 $2 $3",["900"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"GB":[null,[null,null,"\\d{10}","\\d{6,10}"],[null,null,"[1-6]\\d{9}","\\d{6,10}"],[null,null,"7[1-57-9]\\d{8}","\\d{10}"],[null,null,"80\\d{8}","\\d{10}"],[null,null,"9[018]\\d{8}","\\d{10}"],[null,null,"8(?:4[3-5]|7[0-2])\\d{7}","\\d{10}"],[null,null,"70\\d{8}","\\d{10}"],[null,null,"56\\d{8}","\\d{10}"],"GB",44,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[1-59]|[78]0"],"(0$1)","",0],[null,"(\\d)(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3 $4",["6"],"(0$1)","",0],[null,"(\\d{4})(\\d{3})(\\d{3})","$1 $2 $3",["7[1-57-9]"],"(0$1)","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["8[47]"],"(0$1)","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"IT":[null,[null,null,"[0389]\\d{5,10}","\\d{6,11}"],[null,null,"0\\d{9,10}","\\d{10,11}"],[null,null,"3\\d{8,9}","\\d{9,10}"],[null,null,"80(?:0\\d{6}|3\\d{3})","\\d{6,9}"],[null,null,"89(?:2\\d{3}|9\\d{6})","\\d{6,9}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"IT",39,"00",null,null,null,null,null,null,null,[[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["0[26]"],"","",0],[null,"(\\d{3})(\\d{4})(\\d{3,4})","$1 $2 $3",["0[13-57-9]"],"","",0],[null,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["3"],"","",0],[null,"(\\d{3})(\\d{3,6})","$1 $2",["8"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],1,[null,null,"NA","NA"],[null,null,"NA","NA"]],"JP":[null,[null,null,"07\\d{5}|[1-357-9]\\d{3,10}","\\d{4,11}"],[null,null,"07\\d{5}|[1-357-9]\\d{3,10}","\\d{4,11}"],[null,null,"07\\d{5}|[1-357-9]\\d{3,10}","\\d{4,11}"],[null,null,"0777[01]\\d{2}","\\d{7}",null,null,"0777012"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"JP",81,"010","0",null,null,"0",null,null,1,[[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["[57-9]0"],"0$1","",0],[null,"(\\d{2})(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3 $4",["[57-9]0"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{4})","$1 $2 $3",["111|222|333","(?:111|222|333)1","(?:111|222|333)11"],"0$1","",0],[null,"(\\d{4})(\\d)(\\d{4})","$1 $2 $3",["222|333","2221|3332","22212|3332","222120|3332"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{4})","$1 $2 $3",["[23]"],"0$1","",0],[null,"(\\d{3})(\\d{4})","$1-$2",["077"],"0$1","",0],[null,"(\\d{4})","*$1",["[23]"],"$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"[23]\\d{3}","\\d{4}"],[null,null,"NA","NA"],1,[null,null,"NA","NA"],[null,null,"NA","NA"]],"KR":[null,[null,null,"[1-7]\\d{3,9}|8\\d{8}","\\d{4,10}"],[null,null,"(?:2|[34][1-3]|5[1-5]|6[1-4])(?:1\\d{2,3}|[2-9]\\d{6,7})","\\d{4,10}",null,null,"22123456"],[null,null,"1[0-25-9]\\d{7,8}","\\d{9,10}",null,null,"1023456789"],[null,null,"80\\d{7}","\\d{9}",null,null,"801234567"],[null,null,"60[2-9]\\d{6}","\\d{9}",null,null,"602345678"],[null,null,"NA","NA"],[null,null,"50\\d{8}","\\d{10}",null,null,"5012345678"],[null,null,"70\\d{8}","\\d{10}",null,null,"7012345678"],"KR",82,"00(?:[124-68]|[37]\\d{2})","0",null,null,"0(8[1-46-8]|85\\d{2})?",null,null,null,[[null,"(\\d{2})(\\d{4})(\\d{4})","$1-$2-$3",["1(?:0|1[19]|[69]9|5[458])|[57]0","1(?:0|1[19]|[69]9|5(?:44|59|8))|[57]0"],"0$1","",0],[null,"(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3",["1(?:[169][2-8]|[78]|5[1-4])|[68]0|[3-6][1-9][2-9]","1(?:[169][2-8]|[78]|5(?:[1-3]|4[56]))|[68]0|[3-6][1-9][2-9]"],"0$1","",0],[null,"(\\d{3})(\\d)(\\d{4})","$1-$2-$3",["131","1312"],"0$1","",0],[null,"(\\d{3})(\\d{2})(\\d{4})","$1-$2-$3",["131","131[13-9]"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["13[2-9]"],"0$1","",0],[null,"(\\d{2})(\\d{2})(\\d{3})(\\d{4})","$1-$2-$3-$4",["30"],"0$1","",0],[null,"(\\d)(\\d{4})(\\d{4})","$1-$2-$3",["2(?:[26]|3[0-467])","2(?:[26]|3(?:01|1[45]|2[17-9]|39|4|6[67]|7[078]))"],"0$1","",0],[null,"(\\d)(\\d{3})(\\d{4})","$1-$2-$3",["2(?:3[0-35-9]|[457-9])","2(?:3(?:0[02-9]|1[0-36-9]|2[02-6]|3[0-8]|6[0-589]|7[1-69]|[589])|[457-9])"],"0$1","",0],[null,"(\\d)(\\d{3})","$1-$2",["21[0-46-9]","21(?:[0-247-9]|3[124]|6[1269])"],"0$1","",0],[null,"(\\d)(\\d{4})","$1-$2",["21[36]","21(?:3[035-9]|6[03-578])"],"0$1","",0],[null,"(\\d{2})(\\d{3})","$1-$2",["[3-6][1-9]1","[3-6][1-9]1(?:[0-46-9])","[3-6][1-9]1(?:[0-247-9]|3[124]|6[1269])"],"0$1","",0],[null,"(\\d{2})(\\d{4})","$1-$2",["[3-6][1-9]1","[3-6][1-9]1[36]","[3-6][1-9]1(?:3[035-9]|6[03-578])"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"MX":[null,[null,null,"[1-9]\\d{9,10}","\\d{7,11}"],[null,null,"[2-9]\\d{9}","\\d{7,10}"],[null,null,"1\\d{10}","\\d{11}"],[null,null,"800\\d{7}","\\d{10}"],[null,null,"900\\d{7}","\\d{10}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"MX",52,"00","01",null,null,"01|04[45](\\d{10})","1$1",null,null,[[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]00"],"01 $1","",1],[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|55|81"],"01 $1","",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2467]|3[0-24-9]|5[0-46-9]|8[2-9]|9[1-9]"],"01 $1","",1],[null,"(1)(\\d{2})(\\d{4})(\\d{4})","045 $2 $3 $4",["1(?:33|55|81)"],"$1","",0],[null,"(1)(\\d{3})(\\d{3})(\\d{4})","045 $2 $3 $4",["1(?:[124579]|3[0-24-9]|5[0-46-9]|8[02-9])"],"$1","",0]],[[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[89]00","[89]00"],"01 $1","",1],[null,"(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3",["33|55|81","33|55|81"],"01 $1","",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["[2467]|3[0-24-9]|5[0-46-9]|8[2-9]|9[1-9]","[2467]|3[0-24-9]|5[0-46-9]|8[2-9]|9[1-9]"],"01 $1","",1],[null,"(1)(\\d{2})(\\d{4})(\\d{4})","$1 $2 $3 $4",["1(?:33|55|81)"]],[null,"(1)(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3 $4",["1(?:[124579]|3[0-24-9]|5[0-46-9]|8[02-9])"]]],[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"NZ":[null,[null,null,"[289]\\d{7,9}|[3-7]\\d{7}","\\d{7,10}"],[null,null,"24099\\d{3}|(?:3[2-79]|[479][2-689]|6[235-9])\\d{6}","\\d{7,8}"],[null,null,"2(?:[027]\\d{7}|9\\d{6,7}|1(?:0\\d{5,7}|[12]\\d{5,6}|[3-9]\\d{5})|4[1-9]\\d{6}|8\\d{7,8})","\\d{8,10}"],[null,null,"800\\d{6,7}","\\d{9,10}"],[null,null,"900\\d{6,7}","\\d{9,10}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"NZ",64,"00","0",null,null,"0",null,null,null,[[null,"(\\d)(\\d{3})(\\d{4})","$1-$2 $3",["24|[34679]"],"0$1","",0],[null,"(\\d)(\\d{3})(\\d{3,5})","$1-$2 $3",["2[179]"],"0$1","",0],[null,"(\\d{3})(\\d{3})(\\d{3,4})","$1 $2 $3",["[89]"],"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"PL":[null,[null,null,"[1-9]\\d{8}","\\d{9}"],[null,null,"[1-9]\\d{8}","\\d{9}"],[null,null,"(?:5[01]|6[069]|7[289]|88)\\d{7}","\\d{9}"],[null,null,"800\\d{6}","\\d{9}"],[null,null,"70\\d{7}","\\d{9}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"PL",48,"00","0",null,null,"0",null,null,null,[[null,"(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"0$1","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"RE":[null,[null,null,"[268]\\d{8}","\\d{9}"],[null,null,"262\\d{6}","\\d{9}",null,null,"262161234"],[null,null,"6(?:9[23]|47)\\d{6}","\\d{9}",null,null,"692123456"],[null,null,"80\\d{7}","\\d{9}",null,null,"801234567"],[null,null,"8(?:1[01]|2[0156]|84|9[0-37-9])\\d{6}","\\d{9}",null,null,"810123456"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"RE",262,"00","0",null,null,"0",null,null,null,[[null,"([268]\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",null,"0$1","",0]],null,[null,null,"NA","NA"],null,"262|6(?:9[23]|47)|8",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"SG":[null,[null,null,"[13689]\\d{7,10}","\\d{8}|\\d{10,11}"],[null,null,"[36]\\d{7}","\\d{8}"],[null,null,"[89]\\d{7}","\\d{8}"],[null,null,"1?800\\d{7}","\\d{10,11}"],[null,null,"1900\\d{7}","\\d{11}"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"SG",65,"0[0-3][0-9]",null,null,null,"777777",null,null,null,[[null,"(\\d{4})(\\d{4})","$1 $2",["[369]|8[1-9]"],"","",0],[null,"(\\d{4})(\\d{3})(\\d{4})","$1 $2 $3",["1[89]"],"","",0],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",["800"],"","",0]],null,[null,null,"NA","NA"],null,null,[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]],"US":[null,[null,null,"[13-689]\\d{9}|2[0-35-9]\\d{8}","\\d{7}(?:\\d{3})?",null,null,"1234567890"],[null,null,"[13-689]\\d{9}|2[0-35-9]\\d{8}","\\d{7}(?:\\d{3})?",null,null,"1234567890"],[null,null,"[13-689]\\d{9}|2[0-35-9]\\d{8}","\\d{7}(?:\\d{3})?",null,null,"1234567890"],[null,null,"8(?:00|66|77|88)\\d{7}","\\d{10}",null,null,"1234567890"],[null,null,"900\\d{7}","\\d{10}",null,null,"1234567890"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"US",1,"011","1"," extn. ",null,"1",null,null,1,[[null,"(\\d{3})(\\d{4})","$1 $2",null,"","",1],[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",null,"","",1]],[[null,"(\\d{3})(\\d{3})(\\d{4})","$1 $2 $3",null,"","",1]],[null,null,"NA","NA"],1,null,[null,null,"800\\d{7}","\\d{10}",null,null,"1234567890"],[null,null,"NA","NA"],null,[null,null,"119|911","\\d{3}",null,null,"911"],[null,null,"NA","NA"]],"YT":[null,[null,null,"[268]\\d{8}","\\d{9}"],[null,null,"2696[0-4]\\d{4}","\\d{9}",null,null,"269601234"],[null,null,"639\\d{6}","\\d{9}",null,null,"639123456"],[null,null,"80\\d{7}","\\d{9}",null,null,"801234567"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],[null,null,"NA","NA"],"YT",262,"00","0",null,null,"0",null,null,null,null,null,[null,null,"NA","NA"],null,"269|639",[null,null,"NA","NA"],[null,null,"NA","NA"],null,[null,null,"NA","NA"],[null,null,"NA","NA"]]}}
\ No newline at end of file
diff --git a/libPhoneNumber/en.lproj/InfoPlist.strings b/libPhoneNumber/en.lproj/InfoPlist.strings
new file mode 100644
index 0000000..477b28f
--- /dev/null
+++ b/libPhoneNumber/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
diff --git a/libPhoneNumber/libPhoneNumber-Info.plist b/libPhoneNumber/libPhoneNumber-Info.plist
new file mode 100644
index 0000000..07fd24f
--- /dev/null
+++ b/libPhoneNumber/libPhoneNumber-Info.plist
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.nhn.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
diff --git a/libPhoneNumber/libPhoneNumber-Prefix.pch b/libPhoneNumber/libPhoneNumber-Prefix.pch
new file mode 100644
index 0000000..ab2a2dc
--- /dev/null
+++ b/libPhoneNumber/libPhoneNumber-Prefix.pch
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'libPhoneNumber' target in the 'libPhoneNumber' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_3_0
+#warning "This project uses features only available in iOS SDK 3.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
diff --git a/libPhoneNumber/main.m b/libPhoneNumber/main.m
new file mode 100644
index 0000000..f475592
--- /dev/null
+++ b/libPhoneNumber/main.m
@@ -0,0 +1,17 @@
+//
+// main.m
+// libPhoneNumber
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import <UIKit/UIKit.h>
+
+#import "AppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
+ }
+}
diff --git a/libPhoneNumberTests/NBAsYouTypeFormatterTest.h b/libPhoneNumberTests/NBAsYouTypeFormatterTest.h
new file mode 100644
index 0000000..010f00b
--- /dev/null
+++ b/libPhoneNumberTests/NBAsYouTypeFormatterTest.h
@@ -0,0 +1,13 @@
+//
+// NBAsYouTypeFormatterTest.h
+// libPhoneNumber
+//
+// Created by ishtar on 13. 3. 5..
+// Copyright (c) 2013년 NHN. All rights reserved.
+//
+
+#import <SenTestingKit/SenTestingKit.h>
+
+@interface NBAsYouTypeFormatterTest : SenTestCase
+
+@end
diff --git a/libPhoneNumberTests/NBAsYouTypeFormatterTest.m b/libPhoneNumberTests/NBAsYouTypeFormatterTest.m
new file mode 100644
index 0000000..d5b2687
--- /dev/null
+++ b/libPhoneNumberTests/NBAsYouTypeFormatterTest.m
@@ -0,0 +1,1169 @@
+//
+// NBAsYouTypeFormatterTest.m
+// libPhoneNumber
+//
+// Created by ishtar on 13. 3. 5..
+// Copyright (c) 2013년 NHN. All rights reserved.
+//
+
+#import "NBAsYouTypeFormatterTest.h"
+#import "NBAsYouTypeFormatter.h"
+
+@implementation NBAsYouTypeFormatterTest
+
+- (void)setUp
+{
+ [super setUp];
+
+ // ...
+}
+
+- (void)tearDown
+{
+ // ...
+
+ [super tearDown];
+}
+
+- (void)testNSDictionaryalbeKey
+{
+ //testInvalidRegion()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"ZZ"];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+4", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+48 ", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+48 8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+48 88", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+48 88 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+48 88 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+48 88 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+48 88 123 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+48 88 123 12", [f inputDigit:@"2"], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"650", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"6502", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"65025", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"650253", [f inputDigit:@"3"], nil);
+ }
+
+ //testInvalidPlusSign()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"ZZ"];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+4", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+48 ", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+48 8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+48 88", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+48 88 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+48 88 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+48 88 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+48 88 123 1", [f inputDigit:@"1"], nil);
+ // A plus sign can only appear at the beginning of the number;
+ // otherwise, no formatting is applied.
+ STAssertEqualObjects(@"+48881231+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+48881231+2", [f inputDigit:@"2"], nil);
+ }
+
+ //testTooLongNumberMatchingMultipleLeadingDigits()
+ {
+ // See http://code.google.com/p/libphonenumber/issues/detail?id=36
+ // The bug occurred last time for countries which have two formatting rules
+ // with exactly the same leading digits pattern but differ in length.
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"ZZ"];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+81 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+81 9", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"+81 90", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"+81 90 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+81 90 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+81 90 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+81 90 1234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+81 90 1234 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+81 90 1234 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+81 90 1234 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+81 90 1234 5678", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+81 90 12 345 6789", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"+81901234567890", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"+819012345678901", [f inputDigit:@"1"], nil);
+ }
+
+ // testCountryWithSpaceInNationalPrefixFormattingRule()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"BY"];
+ STAssertEqualObjects(@"8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"88", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"881", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"8 819", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"8 8190", [f inputDigit:@"0"], nil);
+ // The formatting rule for 5 digit numbers states that no space should be
+ // present after the national prefix.
+ STAssertEqualObjects(@"881 901", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"8 819 012", [f inputDigit:@"2"], nil);
+ // Too long, no formatting rule applies.
+ STAssertEqualObjects(@"88190123", [f inputDigit:@"3"], nil);
+ }
+
+ // testCountryWithSpaceInNationalPrefixFormattingRuleAndLongNdd()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"BY"];
+ STAssertEqualObjects(@"9", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"99", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"999", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"9999", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"99999 ", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"99999 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"99999 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"99999 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"99999 1234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"99999 12 345", [f inputDigit:@"5"], nil);
+ }
+
+ // testAYTFUS()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
+ STAssertEqualObjects(@"6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"650", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"650 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"650 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"650 253", [f inputDigit:@"3"], nil);
+ // Note this is how a US local number (without area code) should be formatted.
+ STAssertEqualObjects(@"650 2532", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"650 253 22", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"650 253 222", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"650 253 2222", [f inputDigit:@"2"], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"16", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"1 65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"1 650", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"1 650 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1 650 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"1 650 253", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"1 650 253 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1 650 253 22", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1 650 253 222", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1 650 253 2222", [f inputDigit:@"2"], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"01", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 4", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"011 44 ", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"011 44 6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"011 44 61", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 44 6 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"011 44 6 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"011 44 6 123 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 44 6 123 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"011 44 6 123 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"011 44 6 123 123 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 44 6 123 123 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"011 44 6 123 123 123", [f inputDigit:@"3"], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"01", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"011 54 ", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"011 54 9", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"011 54 91", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 54 9 11", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 54 9 11 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"011 54 9 11 23", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"011 54 9 11 231", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 54 9 11 2312", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"011 54 9 11 2312 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 54 9 11 2312 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"011 54 9 11 2312 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"011 54 9 11 2312 1234", [f inputDigit:@"4"], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"01", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"011 24", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"011 244 ", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"011 244 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"011 244 28", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"011 244 280", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"011 244 280 0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"011 244 280 00", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"011 244 280 000", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"011 244 280 000 0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"011 244 280 000 00", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"011 244 280 000 000", [f inputDigit:@"0"], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+4", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+48 ", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+48 8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+48 88", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+48 88 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+48 88 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+48 88 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+48 88 123 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+48 88 123 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+48 88 123 12 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+48 88 123 12 12", [f inputDigit:@"2"], nil);
+ }
+
+ //testAYTFUSFullWidthCharacters()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
+ STAssertEqualObjects(@"\uFF16", [f inputDigit:@"\uFF16"], nil);
+ STAssertEqualObjects(@"\uFF16\uFF15", [f inputDigit:@"\uFF15"], nil);
+ STAssertEqualObjects(@"650", [f inputDigit:@"\uFF10"], nil);
+ STAssertEqualObjects(@"650 2", [f inputDigit:@"\uFF12"], nil);
+ STAssertEqualObjects(@"650 25", [f inputDigit:@"\uFF15"], nil);
+ STAssertEqualObjects(@"650 253", [f inputDigit:@"\uFF13"], nil);
+ STAssertEqualObjects(@"650 2532", [f inputDigit:@"\uFF12"], nil);
+ STAssertEqualObjects(@"650 253 22", [f inputDigit:@"\uFF12"], nil);
+ STAssertEqualObjects(@"650 253 222", [f inputDigit:@"\uFF12"], nil);
+ STAssertEqualObjects(@"650 253 2222", [f inputDigit:@"\uFF12"], nil);
+ }
+
+ // testAYTFUSMobileShortCode()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
+ STAssertEqualObjects(@"*", [f inputDigit:@"*"], nil);
+ STAssertEqualObjects(@"*1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"*12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"*121", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"*121#", [f inputDigit:@"#"], nil);
+ }
+
+ // testAYTFUSVanityNumber()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
+ STAssertEqualObjects(@"8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"80", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"800", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"800 ", [f inputDigit:@" "], nil);
+ STAssertEqualObjects(@"800 M", [f inputDigit:@"M"], nil);
+ STAssertEqualObjects(@"800 MY", [f inputDigit:@"Y"], nil);
+ STAssertEqualObjects(@"800 MY ", [f inputDigit:@" "], nil);
+ STAssertEqualObjects(@"800 MY A", [f inputDigit:@"A"], nil);
+ STAssertEqualObjects(@"800 MY AP", [f inputDigit:@"P"], nil);
+ STAssertEqualObjects(@"800 MY APP", [f inputDigit:@"P"], nil);
+ STAssertEqualObjects(@"800 MY APPL", [f inputDigit:@"L"], nil);
+ STAssertEqualObjects(@"800 MY APPLE", [f inputDigit:@"E"], nil);
+ }
+
+ // testAYTFAndRememberPositionUS()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
+ STAssertEqualObjects(@"1", [f inputDigitAndRememberPosition:@"1"], nil);
+ STAssertEquals((NSInteger)1, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"16", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"1 65", [f inputDigit:@"5"], nil);
+ STAssertEquals((NSInteger)1, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1 650", [f inputDigitAndRememberPosition:@"0"], nil);
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1 650 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1 650 25", [f inputDigit:@"5"], nil);
+ // Note the remembered position for digit '0' changes from 4 to 5, because a
+ // space is now inserted in the front.
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1 650 253", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"1 650 253 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1 650 253 22", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1 650 253 222", [f inputDigitAndRememberPosition:@"2"], nil);
+ STAssertEquals((NSInteger)13, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1 650 253 2222", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)13, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"165025322222", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)10, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1650253222222", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)10, [f getRememberedPosition], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"16", [f inputDigitAndRememberPosition:@"6"], nil);
+ STAssertEquals((NSInteger)2, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1 65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"1 650", [f inputDigit:@"0"], nil);
+ STAssertEquals((NSInteger)3, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1 650 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1 650 25", [f inputDigit:@"5"], nil);
+ STAssertEquals((NSInteger)3, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1 650 253", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"1 650 253 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1 650 253 22", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)3, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1 650 253 222", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1 650 253 2222", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"165025322222", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)2, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"1650253222222", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)2, [f getRememberedPosition], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"650", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"650 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"650 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"650 253", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"650 2532", [f inputDigitAndRememberPosition:@"2"], nil);
+ STAssertEquals((NSInteger)8, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"650 253 22", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)9, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"650 253 222", [f inputDigit:@"2"], nil);
+ // No more formatting when semicolon is entered.
+ STAssertEqualObjects(@"650253222;", [f inputDigit:@";"], nil);
+ STAssertEquals((NSInteger)7, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"650253222;2", [f inputDigit:@"2"], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"650", [f inputDigit:@"0"], nil);
+ // No more formatting when users choose to do their own formatting.
+ STAssertEqualObjects(@"650-", [f inputDigit:@"-"], nil);
+ STAssertEqualObjects(@"650-2", [f inputDigitAndRememberPosition:@"2"], nil);
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"650-25", [f inputDigit:@"5"], nil);
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"650-253", [f inputDigit:@"3"], nil);
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"650-253-", [f inputDigit:@"-"], nil);
+ STAssertEqualObjects(@"650-253-2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"650-253-22", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"650-253-222", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"650-253-2222", [f inputDigit:@"2"], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"01", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 4", [f inputDigitAndRememberPosition:@"4"], nil);
+ STAssertEqualObjects(@"011 48 ", [f inputDigit:@"8"], nil);
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"011 48 8", [f inputDigit:@"8"], nil);
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"011 48 88", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"011 48 88 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 48 88 12", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"011 48 88 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"011 48 88 123 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 48 88 123 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"011 48 88 123 12 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 48 88 123 12 12", [f inputDigit:@"2"], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+1 6", [f inputDigitAndRememberPosition:@"6"], nil);
+ STAssertEqualObjects(@"+1 65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+1 650", [f inputDigit:@"0"], nil);
+ STAssertEquals((NSInteger)4, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"+1 650 2", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)4, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"+1 650 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+1 650 253", [f inputDigitAndRememberPosition:@"3"], nil);
+ STAssertEqualObjects(@"+1 650 253 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+1 650 253 22", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+1 650 253 222", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)10, [f getRememberedPosition], nil);
+
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+1 6", [f inputDigitAndRememberPosition:@"6"], nil);
+ STAssertEqualObjects(@"+1 65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+1 650", [f inputDigit:@"0"], nil);
+ STAssertEquals((NSInteger)4, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"+1 650 2", [f inputDigit:@"2"], nil);
+ STAssertEquals((NSInteger)4, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"+1 650 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+1 650 253", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+1 650 253 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+1 650 253 22", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+1 650 253 222", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+1650253222;", [f inputDigit:@";"], nil);
+ STAssertEquals((NSInteger)3, [f getRememberedPosition], nil);
+ }
+
+ // testAYTFGBFixedLine()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"GB"];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"02", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"020", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"020 7", [f inputDigitAndRememberPosition:@"7"], nil);
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"020 70", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"020 703", [f inputDigit:@"3"], nil);
+ STAssertEquals((NSInteger)5, [f getRememberedPosition], nil);
+ STAssertEqualObjects(@"020 7031", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"020 7031 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"020 7031 30", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"020 7031 300", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"020 7031 3000", [f inputDigit:@"0"], nil);
+ }
+
+ // testAYTFGBTollFree()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"GB"];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"08", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"080", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"080 7", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"080 70", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"080 703", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"080 7031", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"080 7031 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"080 7031 30", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"080 7031 300", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"080 7031 3000", [f inputDigit:@"0"], nil);
+ }
+
+ // testAYTFGBPremiumRate()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"GB"];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"09", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"090", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"090 7", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"090 70", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"090 703", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"090 7031", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"090 7031 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"090 7031 30", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"090 7031 300", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"090 7031 3000", [f inputDigit:@"0"], nil);
+ }
+
+ // testAYTFNZMobile()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"NZ"];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"02", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"021", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"02-11", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"02-112", [f inputDigit:@"2"], nil);
+ // Note the unittest is using fake metadata which might produce non-ideal
+ // results.
+ STAssertEqualObjects(@"02-112 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"02-112 34", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"02-112 345", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"02-112 3456", [f inputDigit:@"6"], nil);
+ }
+
+ // testAYTFDE()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"DE"];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"03", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"030", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"030/1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"030/12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"030/123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"030/1234", [f inputDigit:@"4"], nil);
+
+ // 04134 1234
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"04", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"041", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"041 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"041 34", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"04134 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"04134 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"04134 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"04134 1234", [f inputDigit:@"4"], nil);
+
+ // 08021 2345
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"08", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"080", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"080 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"080 21", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"08021 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"08021 23", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"08021 234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"08021 2345", [f inputDigit:@"5"], nil);
+
+ // 00 1 650 253 2250
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"00", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"00 1 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"00 1 6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"00 1 65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"00 1 650", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"00 1 650 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"00 1 650 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"00 1 650 253", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"00 1 650 253 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"00 1 650 253 22", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"00 1 650 253 222", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"00 1 650 253 2222", [f inputDigit:@"2"], nil);
+ }
+
+ // testAYTFAR()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"AR"];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"01", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 7", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"011 70", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"011 703", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"011 7031", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 7031-3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"011 7031-30", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"011 7031-300", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"011 7031-3000", [f inputDigit:@"0"], nil);
+ }
+
+ // testAYTFARMobile()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"AR"];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+54 ", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+54 9", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"+54 91", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+54 9 11", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+54 9 11 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+54 9 11 23", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+54 9 11 231", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+54 9 11 2312", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+54 9 11 2312 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+54 9 11 2312 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+54 9 11 2312 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+54 9 11 2312 1234", [f inputDigit:@"4"], nil);
+ }
+
+ // testAYTFKR()
+ {
+ // +82 51 234 5678
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"KR"];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+82 ", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+82 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+82 51", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+82 51-2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+82 51-23", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+82 51-234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+82 51-234-5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+82 51-234-56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+82 51-234-567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+82 51-234-5678", [f inputDigit:@"8"], nil);
+
+ // +82 2 531 5678
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+82 ", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+82 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+82 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+82 2-53", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+82 2-531", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+82 2-531-5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+82 2-531-56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+82 2-531-567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+82 2-531-5678", [f inputDigit:@"8"], nil);
+
+ // +82 2 3665 5678
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+82 ", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+82 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+82 23", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+82 2-36", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+82 2-366", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+82 2-3665", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+82 2-3665-5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+82 2-3665-56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+82 2-3665-567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+82 2-3665-5678", [f inputDigit:@"8"], nil);
+
+ // 02-114
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"02", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"021", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"02-11", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"02-114", [f inputDigit:@"4"], nil);
+
+ // 02-1300
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"02", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"021", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"02-13", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"02-130", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"02-1300", [f inputDigit:@"0"], nil);
+
+ // 011-456-7890
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"01", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011-4", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"011-45", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"011-456", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"011-456-7", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"011-456-78", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"011-456-789", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"011-456-7890", [f inputDigit:@"0"], nil);
+
+ // 011-9876-7890
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"01", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011-9", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"011-98", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"011-987", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"011-9876", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"011-9876-7", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"011-9876-78", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"011-9876-789", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"011-9876-7890", [f inputDigit:@"0"], nil);
+ }
+
+ // testAYTF_MX()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"MX"];
+
+ // +52 800 123 4567
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 ", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+52 80", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"+52 800", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"+52 800 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+52 800 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 800 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+52 800 123 4", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+52 800 123 45", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 800 123 456", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+52 800 123 4567", [f inputDigit:@"7"], nil);
+
+ // +52 55 1234 5678
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 ", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 55", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 55 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+52 55 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 55 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+52 55 1234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+52 55 1234 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 55 1234 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+52 55 1234 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+52 55 1234 5678", [f inputDigit:@"8"], nil);
+
+ // +52 212 345 6789
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 ", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 21", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+52 212", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 212 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+52 212 34", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+52 212 345", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 212 345 6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+52 212 345 67", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+52 212 345 678", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+52 212 345 6789", [f inputDigit:@"9"], nil);
+
+ // +52 1 55 1234 5678
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 ", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+52 15", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 1 55", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 1 55 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+52 1 55 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 1 55 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+52 1 55 1234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+52 1 55 1234 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 1 55 1234 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+52 1 55 1234 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+52 1 55 1234 5678", [f inputDigit:@"8"], nil);
+
+ // +52 1 541 234 5678
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 ", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+52 15", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 1 54", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+52 1 541", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+52 1 541 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 1 541 23", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+52 1 541 234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+52 1 541 234 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 1 541 234 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+52 1 541 234 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+52 1 541 234 5678", [f inputDigit:@"8"], nil);
+ }
+
+ // testAYTF_International_Toll_Free()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
+ // +800 1234 5678
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+80", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"+800 ", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"+800 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+800 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+800 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+800 1234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+800 1234 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+800 1234 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+800 1234 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+800 1234 5678", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+800123456789", [f inputDigit:@"9"], nil);
+ }
+
+ // testAYTFMultipleLeadingDigitPatterns()
+ {
+ // +81 50 2345 6789
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"JP"];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+81 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+81 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+81 50", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"+81 50 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+81 50 23", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+81 50 234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+81 50 2345", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+81 50 2345 6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+81 50 2345 67", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+81 50 2345 678", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+81 50 2345 6789", [f inputDigit:@"9"], nil);
+
+ // +81 222 12 5678
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+81 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+81 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+81 22", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+81 22 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+81 22 21", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+81 2221 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+81 222 12 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+81 222 12 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+81 222 12 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+81 222 12 5678", [f inputDigit:@"8"], nil);
+
+ // 011113
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"01", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011 11", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"011113", [f inputDigit:@"3"], nil);
+
+ // +81 3332 2 5678
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+81 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+81 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+81 33", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+81 33 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+81 3332", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+81 3332 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+81 3332 2 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+81 3332 2 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+81 3332 2 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+81 3332 2 5678", [f inputDigit:@"8"], nil);
+ }
+
+ // testAYTFLongIDD_AU()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"AU"];
+ // 0011 1 650 253 2250
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"00", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"001", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"0011", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"0011 1 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"0011 1 6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"0011 1 65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"0011 1 650", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"0011 1 650 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"0011 1 650 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"0011 1 650 253", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"0011 1 650 253 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"0011 1 650 253 22", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"0011 1 650 253 222", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"0011 1 650 253 2222", [f inputDigit:@"2"], nil);
+
+ // 0011 81 3332 2 5678
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"00", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"001", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"0011", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"00118", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"0011 81 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"0011 81 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"0011 81 33", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"0011 81 33 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"0011 81 3332", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"0011 81 3332 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"0011 81 3332 2 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"0011 81 3332 2 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"0011 81 3332 2 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"0011 81 3332 2 5678", [f inputDigit:@"8"], nil);
+
+ // 0011 244 250 253 222
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"00", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"001", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"0011", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"00112", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"001124", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"0011 244 ", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"0011 244 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"0011 244 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"0011 244 250", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"0011 244 250 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"0011 244 250 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"0011 244 250 253", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"0011 244 250 253 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"0011 244 250 253 22", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"0011 244 250 253 222", [f inputDigit:@"2"], nil);
+ }
+
+ // testAYTFLongIDD_KR()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"KR"];
+ // 00300 1 650 253 2222
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"00", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"003", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"0030", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"00300", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"00300 1 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"00300 1 6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"00300 1 65", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"00300 1 650", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"00300 1 650 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"00300 1 650 25", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"00300 1 650 253", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"00300 1 650 253 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"00300 1 650 253 22", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"00300 1 650 253 222", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"00300 1 650 253 2222", [f inputDigit:@"2"], nil);
+ }
+
+ // testAYTFLongNDD_KR()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"KR"];
+ // 08811-9876-7890
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"08", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"088", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"0881", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"08811", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"08811-9", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"08811-98", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"08811-987", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"08811-9876", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"08811-9876-7", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"08811-9876-78", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"08811-9876-789", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"08811-9876-7890", [f inputDigit:@"0"], nil);
+
+ // 08500 11-9876-7890
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"08", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"085", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"0850", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"08500 ", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"08500 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"08500 11", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"08500 11-9", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"08500 11-98", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"08500 11-987", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"08500 11-9876", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"08500 11-9876-7", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"08500 11-9876-78", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"08500 11-9876-789", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"08500 11-9876-7890", [f inputDigit:@"0"], nil);
+ }
+
+ // testAYTFLongNDD_SG()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"SG"];
+ // 777777 9876 7890
+ STAssertEqualObjects(@"7", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"77", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"777", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"7777", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"77777", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"777777 ", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"777777 9", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"777777 98", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"777777 987", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"777777 9876", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"777777 9876 7", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"777777 9876 78", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"777777 9876 789", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"777777 9876 7890", [f inputDigit:@"0"], nil);
+ }
+
+ // testAYTFShortNumberFormattingFix_AU()
+ {
+ // For Australia, the national prefix is not optional when formatting.
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"AU"];
+
+ // 1234567890 - For leading digit 1, the national prefix formatting rule has
+ // first group only.
+ STAssertEqualObjects(@"1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"1234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"1234 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"1234 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"1234 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"1234 567 8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"1234 567 89", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"1234 567 890", [f inputDigit:@"0"], nil);
+
+ // +61 1234 567 890 - Test the same number, but with the country code.
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+61 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+61 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+61 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+61 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+61 1234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+61 1234 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+61 1234 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+61 1234 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+61 1234 567 8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+61 1234 567 89", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"+61 1234 567 890", [f inputDigit:@"0"], nil);
+
+ // 212345678 - For leading digit 2, the national prefix formatting rule puts
+ // the national prefix before the first group.
+ [f clear];
+ STAssertEqualObjects(@"0", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"02", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"021", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"02 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"02 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"02 1234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"02 1234 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"02 1234 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"02 1234 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"02 1234 5678", [f inputDigit:@"8"], nil);
+
+ // 212345678 - Test the same number, but without the leading 0.
+ [f clear];
+ STAssertEqualObjects(@"2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"21", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"212", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"2123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"21234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"212345", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"2123456", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"21234567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"212345678", [f inputDigit:@"8"], nil);
+
+ // +61 2 1234 5678 - Test the same number, but with the country code.
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+6", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+61 ", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+61 2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+61 21", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+61 2 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+61 2 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+61 2 1234", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+61 2 1234 5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+61 2 1234 56", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+61 2 1234 567", [f inputDigit:@"7"], nil);
+ STAssertEqualObjects(@"+61 2 1234 5678", [f inputDigit:@"8"], nil);
+ }
+
+ // testAYTFShortNumberFormattingFix_KR()
+ {
+ // For Korea, the national prefix is not optional when formatting, and the
+ // national prefix formatting rule doesn't consist of only the first group.
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"KR"];
+
+ // 111
+ STAssertEqualObjects(@"1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"11", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"111", [f inputDigit:@"1"], nil);
+
+ // 114
+ [f clear];
+ STAssertEqualObjects(@"1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"11", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"114", [f inputDigit:@"4"], nil);
+
+ // 13121234 - Test a mobile number without the national prefix. Even though it
+ // is not an emergency number, it should be formatted as a block.
+ [f clear];
+ STAssertEqualObjects(@"1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"13", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"131", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"1312", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"13121", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"131212", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1312123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"13121234", [f inputDigit:@"4"], nil);
+
+ // +82 131-2-1234 - Test the same number, but with the country code.
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+82 ", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+82 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+82 13", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+82 131", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+82 131-2", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+82 131-2-1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+82 131-2-12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+82 131-2-123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+82 131-2-1234", [f inputDigit:@"4"], nil);
+ }
+
+ // testAYTFShortNumberFormattingFix_MX()
+ {
+ // For Mexico, the national prefix is optional when formatting.
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"MX"];
+
+ // 911
+ STAssertEqualObjects(@"9", [f inputDigit:@"9"], nil);
+ STAssertEqualObjects(@"91", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"911", [f inputDigit:@"1"], nil);
+
+ // 800 123 4567 - Test a toll-free number, which should have a formatting rule
+ // applied to it even though it doesn't begin with the national prefix.
+ [f clear];
+ STAssertEqualObjects(@"8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"80", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"800", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"800 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"800 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"800 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"800 123 4", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"800 123 45", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"800 123 456", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"800 123 4567", [f inputDigit:@"7"], nil);
+
+ // +52 800 123 4567 - Test the same number, but with the country code.
+ [f clear];
+ STAssertEqualObjects(@"+", [f inputDigit:@"+"], nil);
+ STAssertEqualObjects(@"+5", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 ", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 8", [f inputDigit:@"8"], nil);
+ STAssertEqualObjects(@"+52 80", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"+52 800", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"+52 800 1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"+52 800 12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"+52 800 123", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"+52 800 123 4", [f inputDigit:@"4"], nil);
+ STAssertEqualObjects(@"+52 800 123 45", [f inputDigit:@"5"], nil);
+ STAssertEqualObjects(@"+52 800 123 456", [f inputDigit:@"6"], nil);
+ STAssertEqualObjects(@"+52 800 123 4567", [f inputDigit:@"7"], nil);
+ }
+
+ // testAYTFNoNationalPrefix()
+ {
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"IT"];
+ STAssertEqualObjects(@"3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"33", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"333", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"333 3", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"333 33", [f inputDigit:@"3"], nil);
+ STAssertEqualObjects(@"333 333", [f inputDigit:@"3"], nil);
+ }
+
+ // testAYTFShortNumberFormattingFix_US()
+ {
+ // For the US, an initial 1 is treated specially.
+ /** @type {i18n.phonenumbers.AsYouTypeFormatter} */
+ NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCodeForTest:@"US"];
+
+ // 101 - Test that the initial 1 is not treated as a national prefix.
+ STAssertEqualObjects(@"1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"10", [f inputDigit:@"0"], nil);
+ STAssertEqualObjects(@"101", [f inputDigit:@"1"], nil);
+
+ // 112 - Test that the initial 1 is not treated as a national prefix.
+ [f clear];
+ STAssertEqualObjects(@"1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"11", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"112", [f inputDigit:@"2"], nil);
+
+ // 122 - Test that the initial 1 is treated as a national prefix.
+ [f clear];
+ STAssertEqualObjects(@"1", [f inputDigit:@"1"], nil);
+ STAssertEqualObjects(@"12", [f inputDigit:@"2"], nil);
+ STAssertEqualObjects(@"1 22", [f inputDigit:@"2"], nil);
+ }
+}
+
+@end
diff --git a/libPhoneNumberTests/NBPhoneNumberUtilTests.h b/libPhoneNumberTests/NBPhoneNumberUtilTests.h
new file mode 100644
index 0000000..a28c48d
--- /dev/null
+++ b/libPhoneNumberTests/NBPhoneNumberUtilTests.h
@@ -0,0 +1,11 @@
+//
+// NBPhoneNumberUtilTests.h
+// NBPhoneNumberUtilTests
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import <SenTestingKit/SenTestingKit.h>
+
+@interface NBPhoneNumberUtilTests : SenTestCase
+@end
diff --git a/libPhoneNumberTests/NBPhoneNumberUtilTests.m b/libPhoneNumberTests/NBPhoneNumberUtilTests.m
new file mode 100644
index 0000000..05a1761
--- /dev/null
+++ b/libPhoneNumberTests/NBPhoneNumberUtilTests.m
@@ -0,0 +1,2687 @@
+//
+// NBPhoneNumberUtilTests.m
+// NBPhoneNumberUtilTests
+//
+// Created by NHN Corp. Last Edited by BAND dev team (band_dev@nhn.com)
+//
+
+#import "NBPhoneNumberUtilTests.h"
+
+#import "NBPhoneMetaData.h"
+#import "NBPhoneNumber.h"
+#import "NBPhoneNumberDesc.h"
+#import "NBPhoneNumberUtil.h"
+#import "NBNumberFormat.h"
+
+
+@interface NBPhoneNumberUtil (FOR_UNIT_TEST)
+
+- (NBPhoneNumber*)getExampleNumber:(NSString*)regionCode;
+- (NBPhoneNumber*)getExampleNumberForType:(NSString*)regionCode type:(NBEPhoneNumberType)type;
+- (NBPhoneNumber*)getExampleNumberForNonGeoEntity:(NSNumber*)countryCallingCode;
+- (NBPhoneMetaData*)getMetadataForRegion:(NSString*)regionCode;
+- (BOOL)canBeInternationallyDialled:(NBPhoneNumber*)number;
+- (BOOL)truncateTooLongNumber:(NBPhoneNumber*)number;
+- (NBEValidationResult)isPossibleNumberWithReason:(NBPhoneNumber*)number;
+- (BOOL)isPossibleNumber:(NBPhoneNumber*)number;
+- (BOOL)isPossibleNumberString:(NSString*)number regionDialingFrom:(NSString*)regionDialingFrom;
+- (NBEMatchType)isNumberMatch:(id)firstNumberIn second:(id)secondNumberIn;
+- (NSUInteger)getLengthOfGeographicalAreaCode:(NBPhoneNumber*)phoneNumber;
+- (NSUInteger)getLengthOfNationalDestinationCode:(NBPhoneNumber*)phoneNumber;
+- (BOOL)maybeStripNationalPrefixAndCarrierCode:(NSString**)numberStr metadata:(NBPhoneMetaData*)metadata carrierCode:(NSString**)carrierCode;
+- (NBECountryCodeSource)maybeStripInternationalPrefixAndNormalize:(NSString**)numberStr possibleIddPrefix:(NSString*)possibleIddPrefix;
+- (NSNumber*)maybeExtractCountryCode:(NSString*)number metadata:(NBPhoneMetaData*)defaultRegionMetadata
+ nationalNumber:(NSString**)nationalNumber keepRawInput:(BOOL)keepRawInput phoneNumber:(NBPhoneNumber**)phoneNumber;
+- (NBPhoneNumber*)parse:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion;
+- (NBPhoneNumber*)parseAndKeepRawInput:(NSString*)numberToParse defaultRegion:(NSString*)defaultRegion;
+- (NSString*)format:(NBPhoneNumber*)phoneNumber numberFormat:(NBEPhoneNumberFormat)numberFormat;
+- (NSString*)formatByPattern:(NBPhoneNumber*)number numberFormat:(NBEPhoneNumberFormat)numberFormat userDefinedFormats:(NSArray*)userDefinedFormats;
+- (NSString*)formatNumberForMobileDialing:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom withFormatting:(BOOL)withFormatting;
+- (NSString*)formatOutOfCountryCallingNumber:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom;
+- (NSString*)formatOutOfCountryKeepingAlphaChars:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom;
+- (NSString*)formatNationalNumberWithCarrierCode:(NBPhoneNumber*)number carrierCode:(NSString*)carrierCode;
+- (NSString*)formatInOriginalFormat:(NBPhoneNumber*)number regionCallingFrom:(NSString*)regionCallingFrom;
+- (NSString*)formatNationalNumberWithPreferredCarrierCode:(NBPhoneNumber*)number fallbackCarrierCode:(NSString*)fallbackCarrierCode;
+
+@end
+
+
+@implementation NBPhoneNumberUtilTests
+
+- (void)setUp
+{
+ [super setUp];
+
+ // ...
+}
+
+- (void)tearDown
+{
+ // ...
+
+ [super tearDown];
+}
+
+- (NSString*)stringForNumberType:(NBEPhoneNumberType)type
+{
+ NSString *stringType = @"UNKNOWN";
+
+ switch (type) {
+ case 0: return @"FIXED_LINE";
+ case 1: return @"MOBILE";
+ case 2: return @"FIXED_LINE_OR_MOBILE";
+ case 3: return @"TOLL_FREE";
+ case 4: return @"PREMIUM_RATE";
+ case 5: return @"SHARED_COST";
+ case 6: return @"VOIP";
+ case 7: return @"PERSONAL_NUMBER";
+ case 8: return @"PAGER";
+ case 9: return @"UAN";
+ case 10: return @"VOICEMAIL";
+ default:
+ break;
+ }
+
+ return stringType;
+}
+
+
+// FIXME: This unit test ALWAYS FAIL ... until google libPhoneNumber fix this issue
+- (void)testAustriaNationalNumberParsing
+{
+ NSError *aError = nil;
+
+ NBPhoneNumberUtil *phoneUtil = [NBPhoneNumberUtil sharedInstance];
+ NSString *internationalNumberForInput = @"436606545646";
+ NSString *nationalNumberForExpect = @"6606545646";
+ NSString *defaultRegion = @"AT";
+
+ NBPhoneNumber *phoneNumber = [phoneUtil parse:internationalNumberForInput defaultRegion:defaultRegion error:&aError];
+ NSString *nationalNumberForActual = [NSString stringWithFormat:@"%@", phoneNumber.nationalNumber];
+
+ // ALWAYS FAIL need fix "google libPhoneNumber"
+ STAssertEqualObjects(nationalNumberForExpect, nationalNumberForActual, nil);
+}
+
+
+- (void)testNSDictionaryalbeKey
+{
+ NBPhoneNumberUtil *phoneUtil = [NBPhoneNumberUtil sharedInstance];
+ NSError *aError = nil;
+
+ NBPhoneNumber *myNumber1 = [phoneUtil parse:@"971600123456" defaultRegion:@"AE" error:&aError];
+ NBPhoneNumber *myNumber2 = [phoneUtil parse:@"5491187654321" defaultRegion:@"AR" error:&aError];
+ NBPhoneNumber *myNumber3 = [phoneUtil parse:@"12423570000" defaultRegion:@"BS" error:&aError];
+ NBPhoneNumber *myNumber4 = [phoneUtil parse:@"39236618300" defaultRegion:@"IT" error:&aError];
+ NBPhoneNumber *myNumber5 = [phoneUtil parse:@"16502530000" defaultRegion:@"US" error:&aError];
+
+ NSMutableDictionary *dicTest = [[NSMutableDictionary alloc] init];
+ [dicTest setObject:@"AE" forKey:myNumber1];
+ [dicTest setObject:@"AR" forKey:myNumber2];
+ [dicTest setObject:@"BS" forKey:myNumber3];
+ [dicTest setObject:@"IT" forKey:myNumber4];
+ [dicTest setObject:@"US" forKey:myNumber5];
+
+ NSLog(@"%@", [dicTest objectForKey:myNumber1]);
+ NSLog(@"%@", [dicTest objectForKey:myNumber2]);
+ NSLog(@"%@", [dicTest objectForKey:myNumber3]);
+ NSLog(@"%@", [dicTest objectForKey:myNumber4]);
+ NSLog(@"%@", [dicTest objectForKey:myNumber5]);
+}
+
+
+- (void)testWithRealData
+{
+ NBPhoneNumberUtil *phoneUtil = [NBPhoneNumberUtil sharedInstance];
+
+#pragma mark - customTest
+ NSLog(@"-------------- customTest");
+
+ NSError *aError = nil;
+ NBPhoneNumber *myNumber = [phoneUtil parse:@"6766077303" defaultRegion:@"AT" error:&aError];
+ if (aError == nil)
+ {
+ NSLog(@"isValidPhoneNumber ? [%@]", [phoneUtil isValidNumber:myNumber] ? @"YES":@"NO");
+ NSLog(@"E164 : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatE164 error:&aError]);
+ NSLog(@"INTERNATIONAL : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL error:&aError]);
+ NSLog(@"NATIONAL : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatNATIONAL error:&aError]);
+ NSLog(@"RFC3966 : %@", [phoneUtil format:myNumber numberFormat:NBEPhoneNumberFormatRFC3966 error:&aError]);
+ }
+ else
+ {
+ NSLog(@"Error : %@", [aError localizedDescription]);
+ }
+
+ NSLog (@"extractCountryCode [%@]", [phoneUtil extractCountryCode:@"823213123123" nationalNumber:nil]);
+ NSString *res = nil;
+ NSNumber *dRes = [phoneUtil extractCountryCode:@"823213123123" nationalNumber:&res];
+ NSLog (@"extractCountryCode [%@] [%@]", dRes, res);
+}
+
+
+- (void)testWithTestData
+{
+ // NSError *aError = nil;
+
+ NBPhoneNumberUtil *phoneUtil = [NBPhoneNumberUtil sharedInstanceForTest];
+
+ // Set up some test numbers to re-use.
+ // TODO: Rewrite this as static functions that return new numbers each time to
+ // avoid any risk of accidental changes to mutable static state affecting many
+ // tests.
+ NBPhoneNumber *ALPHA_NUMERIC_NUMBER = [[NBPhoneNumber alloc] init];
+ ALPHA_NUMERIC_NUMBER.countryCode = @1;
+ ALPHA_NUMERIC_NUMBER.nationalNumber = @80074935247;
+
+ NBPhoneNumber *AE_UAN = [[NBPhoneNumber alloc] init];
+ AE_UAN.countryCode = @971;
+ AE_UAN.nationalNumber = @600123456;
+
+ NBPhoneNumber *AR_MOBILE = [[NBPhoneNumber alloc] init];
+ AR_MOBILE.countryCode = @54;
+ AR_MOBILE.nationalNumber = @91187654321;
+
+ NBPhoneNumber *AR_NUMBER = [[NBPhoneNumber alloc] init];
+ AR_NUMBER.countryCode = @54;
+ AR_NUMBER.nationalNumber = @1187654321;
+
+ NBPhoneNumber *AU_NUMBER = [[NBPhoneNumber alloc] init];
+ AU_NUMBER.countryCode = @61;
+ AU_NUMBER.nationalNumber = @236618300;
+
+ NBPhoneNumber *BS_MOBILE = [[NBPhoneNumber alloc] init];
+ BS_MOBILE.countryCode = @1;
+ BS_MOBILE.nationalNumber = @2423570000;
+
+ NBPhoneNumber *BS_NUMBER = [[NBPhoneNumber alloc] init];
+ BS_NUMBER.countryCode = @1;
+ BS_NUMBER.nationalNumber = @2423651234;
+
+ // Note that this is the same as the example number for DE in the metadata.
+ NBPhoneNumber *DE_NUMBER = [[NBPhoneNumber alloc] init];
+ DE_NUMBER.countryCode = @49;
+ DE_NUMBER.nationalNumber = @30123456;
+
+ NBPhoneNumber *DE_SHORT_NUMBER = [[NBPhoneNumber alloc] init];
+ DE_SHORT_NUMBER.countryCode = @49;
+ DE_SHORT_NUMBER.nationalNumber = @1234;
+
+ NBPhoneNumber *GB_MOBILE = [[NBPhoneNumber alloc] init];
+ GB_MOBILE.countryCode = @44;
+ GB_MOBILE.nationalNumber = @7912345678;
+
+ NBPhoneNumber *GB_NUMBER = [[NBPhoneNumber alloc] init];
+ GB_NUMBER.countryCode = @44;
+ GB_NUMBER.nationalNumber = @2070313000;
+
+ NBPhoneNumber *IT_MOBILE = [[NBPhoneNumber alloc] init];
+ IT_MOBILE.countryCode = @39;
+ IT_MOBILE.nationalNumber = @345678901;
+
+ NBPhoneNumber *IT_NUMBER = [[NBPhoneNumber alloc] init];
+ IT_NUMBER.countryCode = @39;
+ IT_NUMBER.nationalNumber = @236618300;
+ IT_NUMBER.italianLeadingZero = YES;
+
+ NBPhoneNumber *JP_STAR_NUMBER = [[NBPhoneNumber alloc] init];
+ JP_STAR_NUMBER.countryCode = @81;
+ JP_STAR_NUMBER.nationalNumber = @2345;
+
+ // Numbers to test the formatting rules from Mexico.
+ NBPhoneNumber *MX_MOBILE1 = [[NBPhoneNumber alloc] init];
+ MX_MOBILE1.countryCode = @52;
+ MX_MOBILE1.nationalNumber = @12345678900;
+
+ NBPhoneNumber *MX_MOBILE2 = [[NBPhoneNumber alloc] init];
+ MX_MOBILE2.countryCode = @52;
+ MX_MOBILE2.nationalNumber = @15512345678;
+
+ NBPhoneNumber *MX_NUMBER1 = [[NBPhoneNumber alloc] init];
+ MX_NUMBER1.countryCode = @52;
+ MX_NUMBER1.nationalNumber = @3312345678;
+
+ NBPhoneNumber *MX_NUMBER2 = [[NBPhoneNumber alloc] init];
+ MX_NUMBER2.countryCode = @52;
+ MX_NUMBER2.nationalNumber = @8211234567;
+
+ NBPhoneNumber *NZ_NUMBER = [[NBPhoneNumber alloc] init];
+ NZ_NUMBER.countryCode = @64;
+ NZ_NUMBER.nationalNumber = @33316005;
+
+ NBPhoneNumber *SG_NUMBER = [[NBPhoneNumber alloc] init];
+ SG_NUMBER.countryCode = @65;
+ SG_NUMBER.nationalNumber = @65218000;
+
+ // A too-long and hence invalid US number.
+ NBPhoneNumber *US_LONG_NUMBER = [[NBPhoneNumber alloc] init];
+ US_LONG_NUMBER.countryCode = @1;
+ US_LONG_NUMBER.nationalNumber = @65025300001;
+
+ NBPhoneNumber *US_NUMBER = [[NBPhoneNumber alloc] init];
+ US_NUMBER.countryCode = @1;
+ US_NUMBER.nationalNumber = @6502530000;
+
+ NBPhoneNumber *US_PREMIUM = [[NBPhoneNumber alloc] init];
+ US_PREMIUM.countryCode = @1;
+ US_PREMIUM.nationalNumber = @9002530000;
+
+ // Too short, but still possible US numbers.
+ NBPhoneNumber *US_LOCAL_NUMBER = [[NBPhoneNumber alloc] init];
+ US_LOCAL_NUMBER.countryCode = @1;
+ US_LOCAL_NUMBER.nationalNumber = @2530000;
+
+ NBPhoneNumber *US_SHORT_BY_ONE_NUMBER = [[NBPhoneNumber alloc] init];
+ US_SHORT_BY_ONE_NUMBER.countryCode = @1;
+ US_SHORT_BY_ONE_NUMBER.nationalNumber = @650253000;
+
+ NBPhoneNumber *US_TOLLFREE = [[NBPhoneNumber alloc] init];
+ US_TOLLFREE.countryCode = @1;
+ US_TOLLFREE.nationalNumber = @8002530000;
+
+ NBPhoneNumber *US_SPOOF = [[NBPhoneNumber alloc] init];
+ US_SPOOF.countryCode = @1;
+ US_SPOOF.nationalNumber = @0;
+
+ NBPhoneNumber *US_SPOOF_WITH_RAW_INPUT = [[NBPhoneNumber alloc] init];
+ US_SPOOF_WITH_RAW_INPUT.countryCode = @1;
+ US_SPOOF_WITH_RAW_INPUT.nationalNumber = @0;
+ US_SPOOF_WITH_RAW_INPUT.rawInput = @"000-000-0000";
+
+ NBPhoneNumber *INTERNATIONAL_TOLL_FREE = [[NBPhoneNumber alloc] init];
+ INTERNATIONAL_TOLL_FREE.countryCode = @800;
+ INTERNATIONAL_TOLL_FREE.nationalNumber = @12345678;
+
+ // We set this to be the same length as numbers for the other non-geographical
+ // country prefix that we have in our test metadata. However, this is not
+ // considered valid because they differ in their country calling code.
+
+ NBPhoneNumber *INTERNATIONAL_TOLL_FREE_TOO_LONG = [[NBPhoneNumber alloc] init];
+ INTERNATIONAL_TOLL_FREE_TOO_LONG.countryCode = @800;
+ INTERNATIONAL_TOLL_FREE_TOO_LONG.nationalNumber = @123456789;
+
+ NBPhoneNumber *UNIVERSAL_PREMIUM_RATE = [[NBPhoneNumber alloc] init];
+ UNIVERSAL_PREMIUM_RATE.countryCode = @979;
+ UNIVERSAL_PREMIUM_RATE.nationalNumber = @123456789;
+
+ NBPhoneNumber *UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT = [[NBPhoneNumber alloc] init];
+ UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT.countryCode = @2;
+ UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT.nationalNumber = @12345;
+
+
+ #pragma mark - testGetInstanceLoadUSMetadata
+ {
+ NBPhoneMetaData *metadata = [phoneUtil getMetadataForRegion:@"US"];
+
+ STAssertEqualObjects(@"US", metadata.codeID, nil);
+ STAssertTrue([metadata.countryCode isEqualToNumber:@1], nil);
+ STAssertEqualObjects(@"011", metadata.internationalPrefix, nil);
+ STAssertTrue(metadata.nationalPrefix != nil, nil);
+ STAssertEquals(2, (int)[metadata.numberFormats count], nil);
+ STAssertEqualObjects(@"(\\d{3})(\\d{3})(\\d{4})", ((NBNumberFormat*)metadata.numberFormats[1]).pattern, nil);
+ STAssertEqualObjects(@"$1 $2 $3", ((NBNumberFormat*)metadata.numberFormats[1]).format, nil);
+ STAssertEqualObjects(@"[13-689]\\d{9}|2[0-35-9]\\d{8}", metadata.generalDesc.nationalNumberPattern, nil);
+ STAssertEqualObjects(@"\\d{7}(?:\\d{3})?", metadata.generalDesc.possibleNumberPattern, nil);
+ STAssertTrue([metadata.generalDesc isEqual:metadata.fixedLine], nil);
+ STAssertEqualObjects(@"\\d{10}", metadata.tollFree.possibleNumberPattern, nil);
+ STAssertEqualObjects(@"900\\d{7}", metadata.premiumRate.nationalNumberPattern, nil);
+ // No shared-cost data is available, so it should be initialised to 'NA'.
+ STAssertEqualObjects(@"NA", metadata.sharedCost.nationalNumberPattern, nil);
+ STAssertEqualObjects(@"NA", metadata.sharedCost.possibleNumberPattern, nil);
+ }
+
+ #pragma mark - testGetInstanceLoadDEMetadata
+ {
+ NBPhoneMetaData *metadata = [phoneUtil getMetadataForRegion:@"DE"];
+ STAssertEqualObjects(@"DE", metadata.codeID, nil);
+ STAssertTrue([metadata.countryCode isEqualToNumber:@49], nil);
+ STAssertEqualObjects(@"00", metadata.internationalPrefix, nil);
+ STAssertEqualObjects(@"0", metadata.nationalPrefix, nil);
+ STAssertEquals(6, (int)[metadata.numberFormats count], nil);
+ STAssertEquals(1, (int)[((NBNumberFormat*)metadata.numberFormats[5]).leadingDigitsPatterns count], nil);
+ STAssertEqualObjects(@"900", ((NBNumberFormat*)metadata.numberFormats[5]).leadingDigitsPatterns[0], nil);
+ STAssertEqualObjects(@"(\\d{3})(\\d{3,4})(\\d{4})", ((NBNumberFormat*)metadata.numberFormats[5]).pattern, nil);
+ STAssertEqualObjects(@"$1 $2 $3", ((NBNumberFormat*)metadata.numberFormats[5]).format, nil);
+ STAssertEqualObjects(@"(?:[24-6]\\d{2}|3[03-9]\\d|[789](?:[1-9]\\d|0[2-9]))\\d{1,8}", metadata.fixedLine.nationalNumberPattern, nil);
+ STAssertEqualObjects(@"\\d{2,14}", metadata.fixedLine.possibleNumberPattern, nil);
+ STAssertEqualObjects(@"30123456", metadata.fixedLine.exampleNumber, nil);
+ STAssertEqualObjects(@"\\d{10}", metadata.tollFree.possibleNumberPattern, nil);
+ STAssertEqualObjects(@"900([135]\\d{6}|9\\d{7})", metadata.premiumRate.nationalNumberPattern, nil);
+ }
+
+
+ #pragma mark - testGetInstanceLoadARMetadata
+ {
+ NBPhoneMetaData *metadata = [phoneUtil getMetadataForRegion:@"AR"];
+ STAssertEqualObjects(@"AR", metadata.codeID, nil);
+ STAssertTrue([metadata.countryCode isEqualToNumber:@54], nil);
+ STAssertEqualObjects(@"00", metadata.internationalPrefix, nil);
+ STAssertEqualObjects(@"0", metadata.nationalPrefix, nil);
+ STAssertEqualObjects(@"0(?:(11|343|3715)15)?", metadata.nationalPrefixForParsing, nil);
+ STAssertEqualObjects(@"9$1", metadata.nationalPrefixTransformRule, nil);
+ STAssertEqualObjects(@"$2 15 $3-$4", ((NBNumberFormat*)metadata.numberFormats[2]).format, nil);
+ STAssertEqualObjects(@"(9)(\\d{4})(\\d{2})(\\d{4})", ((NBNumberFormat*)metadata.numberFormats[3]).pattern, nil);
+ STAssertEqualObjects(@"(9)(\\d{4})(\\d{2})(\\d{4})", ((NBNumberFormat*)metadata.intlNumberFormats[3]).pattern, nil);
+ STAssertEqualObjects(@"$1 $2 $3 $4", ((NBNumberFormat*)metadata.intlNumberFormats[3]).format, nil);
+ }
+
+
+ #pragma mark - testGetInstanceLoadInternationalTollFreeMetadata
+ {
+ NBPhoneMetaData *metadata = [phoneUtil getMetadataForNonGeographicalRegion:@800];
+ STAssertEqualObjects(@"001", metadata.codeID, nil);
+ STAssertTrue([metadata.countryCode isEqualToNumber:@800], nil);
+ STAssertEqualObjects(@"$1 $2", ((NBNumberFormat*)metadata.numberFormats[0]).format, nil);
+ STAssertEqualObjects(@"(\\d{4})(\\d{4})", ((NBNumberFormat*)metadata.numberFormats[0]).pattern, nil);
+ STAssertEqualObjects(@"12345678", metadata.generalDesc.exampleNumber, nil);
+ STAssertEqualObjects(@"12345678", metadata.tollFree.exampleNumber, nil);
+ }
+
+
+ #pragma mark - testIsNumberGeographical
+ {
+ // Bahamas, mobile phone number.
+ STAssertFalse([phoneUtil isNumberGeographical:BS_MOBILE], nil);
+ // Australian fixed line number.
+ STAssertTrue([phoneUtil isNumberGeographical:AU_NUMBER], nil);
+ // International toll free number.
+ STAssertFalse([phoneUtil isNumberGeographical:INTERNATIONAL_TOLL_FREE], nil);
+ }
+
+
+ #pragma mark - testIsLeadingZeroPossible
+ {
+ // Italy
+ STAssertTrue([phoneUtil isLeadingZeroPossible:@39], nil);
+ // USA
+ STAssertFalse([phoneUtil isLeadingZeroPossible:@1], nil);
+ // International toll free
+ STAssertTrue([phoneUtil isLeadingZeroPossible:@800], nil);
+ // International premium-rate
+ STAssertFalse([phoneUtil isLeadingZeroPossible:@979], nil);
+ // Not in metadata file, just default to false.
+ STAssertFalse([phoneUtil isLeadingZeroPossible:@888], nil);
+ }
+
+
+ #pragma mark - testgetLengthOfGeographicalAreaCode
+ {
+ // Google MTV, which has area code '650'.
+ STAssertEquals((NSUInteger)3, [phoneUtil getLengthOfGeographicalAreaCode:US_NUMBER], nil);
+
+ // A North America toll-free number, which has no area code.
+ STAssertEquals((NSUInteger)0, [phoneUtil getLengthOfGeographicalAreaCode:US_TOLLFREE], nil);
+
+ // Google London, which has area code '20'.
+ STAssertEquals((NSUInteger)2, [phoneUtil getLengthOfGeographicalAreaCode:GB_NUMBER], nil);
+
+ // A UK mobile phone, which has no area code.
+ STAssertEquals((NSUInteger)0, [phoneUtil getLengthOfGeographicalAreaCode:GB_MOBILE], nil);
+
+ // Google Buenos Aires, which has area code '11'.
+ STAssertEquals((NSUInteger)2, [phoneUtil getLengthOfGeographicalAreaCode:AR_NUMBER], nil);
+
+ // Google Sydney, which has area code '2'.
+ STAssertEquals((NSUInteger)1, [phoneUtil getLengthOfGeographicalAreaCode:AU_NUMBER], nil);
+
+ // Italian numbers - there is no national prefix, but it still has an area
+ // code.
+ STAssertEquals((NSUInteger)2, [phoneUtil getLengthOfGeographicalAreaCode:IT_NUMBER], nil);
+
+ // Google Singapore. Singapore has no area code and no national prefix.
+ STAssertEquals((NSUInteger)0, [phoneUtil getLengthOfGeographicalAreaCode:SG_NUMBER], nil);
+
+ // An invalid US number (1 digit shorter), which has no area code.
+ STAssertEquals((NSUInteger)0, [phoneUtil getLengthOfGeographicalAreaCode:US_SHORT_BY_ONE_NUMBER], nil);
+
+ // An international toll free number, which has no area code.
+ STAssertEquals((NSUInteger)0, [phoneUtil getLengthOfGeographicalAreaCode:INTERNATIONAL_TOLL_FREE], nil);
+ }
+
+
+ #pragma mark - testGetLengthOfNationalDestinationCode
+ {
+ // Google MTV, which has national destination code (NDC) '650'.
+ STAssertEquals((NSUInteger)3, [phoneUtil getLengthOfNationalDestinationCode:US_NUMBER], nil);
+
+ // A North America toll-free number, which has NDC '800'.
+ STAssertEquals((NSUInteger)3, [phoneUtil getLengthOfNationalDestinationCode:US_TOLLFREE], nil);
+
+ // Google London, which has NDC '20'.
+ STAssertEquals((NSUInteger)2, [phoneUtil getLengthOfNationalDestinationCode:GB_NUMBER], nil);
+
+ // A UK mobile phone, which has NDC '7912'.
+ STAssertEquals((NSUInteger)4, [phoneUtil getLengthOfNationalDestinationCode:GB_MOBILE], nil);
+
+ // Google Buenos Aires, which has NDC '11'.
+ STAssertEquals((NSUInteger)2, [phoneUtil getLengthOfNationalDestinationCode:AR_NUMBER], nil);
+
+ // An Argentinian mobile which has NDC '911'.
+ STAssertEquals((NSUInteger)3, [phoneUtil getLengthOfNationalDestinationCode:AR_MOBILE], nil);
+
+ // Google Sydney, which has NDC '2'.
+ STAssertEquals((NSUInteger)1, [phoneUtil getLengthOfNationalDestinationCode:AU_NUMBER], nil);
+
+ // Google Singapore, which has NDC '6521'.
+ STAssertEquals((NSUInteger)4, [phoneUtil getLengthOfNationalDestinationCode:SG_NUMBER], nil);
+
+ // An invalid US number (1 digit shorter), which has no NDC.
+ STAssertEquals((NSUInteger)0,
+ [phoneUtil getLengthOfNationalDestinationCode:US_SHORT_BY_ONE_NUMBER], nil);
+
+ // A number containing an invalid country calling code, which shouldn't have
+ // any NDC.
+
+ NBPhoneNumber *number = [[NBPhoneNumber alloc] init];
+ [number setCountryCode:@123];
+ [number setNationalNumber:@6502530000];
+ STAssertEquals((NSUInteger)0, [phoneUtil getLengthOfNationalDestinationCode:number], nil);
+
+ // An international toll free number, which has NDC '1234'.
+ STAssertEquals((NSUInteger)4, [phoneUtil getLengthOfNationalDestinationCode:INTERNATIONAL_TOLL_FREE], nil);
+ }
+
+ #pragma mark - testGetNationalSignificantNumber
+ {
+ STAssertEqualObjects(@"6502530000", [phoneUtil getNationalSignificantNumber:US_NUMBER], nil);
+
+ // An Italian mobile number.
+ STAssertEqualObjects(@"345678901", [phoneUtil getNationalSignificantNumber:IT_MOBILE], nil);
+
+ // An Italian fixed line number.
+ STAssertEqualObjects(@"0236618300", [phoneUtil getNationalSignificantNumber:IT_NUMBER], nil);
+
+ STAssertEqualObjects(@"12345678", [phoneUtil getNationalSignificantNumber:INTERNATIONAL_TOLL_FREE], nil);
+ }
+
+
+ #pragma mark - testGetExampleNumber
+ {
+ STAssertTrue([DE_NUMBER isEqual:[phoneUtil getExampleNumber:@"DE"]], nil);
+
+ STAssertTrue([DE_NUMBER isEqual:[phoneUtil getExampleNumberForType:@"DE" type:NBEPhoneNumberTypeFIXED_LINE]], nil);
+ STAssertNil([phoneUtil getExampleNumberForType:@"DE" type:NBEPhoneNumberTypeMOBILE], nil);
+ // For the US, the example number is placed under general description, and
+ // hence should be used for both fixed line and mobile, so neither of these
+ // should return nil.
+ STAssertNotNil([phoneUtil getExampleNumberForType:@"US" type:NBEPhoneNumberTypeFIXED_LINE], nil);
+ STAssertNotNil([phoneUtil getExampleNumberForType:@"US" type:NBEPhoneNumberTypeMOBILE], nil);
+ // CS is an invalid region, so we have no data for it.
+ STAssertNil([phoneUtil getExampleNumberForType:@"CS" type:NBEPhoneNumberTypeMOBILE], nil);
+ // RegionCode 001 is reserved for supporting non-geographical country calling
+ // code. We don't support getting an example number for it with this method.
+ STAssertNil([phoneUtil getExampleNumber:@"001"], nil);
+ }
+
+
+ #pragma mark - testexampleNumberForNonGeoEntity
+ {
+ STAssertTrue([INTERNATIONAL_TOLL_FREE isEqual:[phoneUtil getExampleNumberForNonGeoEntity:@800]], nil);
+ STAssertTrue([UNIVERSAL_PREMIUM_RATE isEqual:[phoneUtil getExampleNumberForNonGeoEntity:@979]], nil);
+ }
+
+
+ #pragma mark - testConvertAlphaCharactersInNumber
+ {
+ NSString *input = @"1800-ABC-DEF";
+ // Alpha chars are converted to digits; everything else is left untouched.
+
+ NSString *expectedOutput = @"1800-222-333";
+ STAssertEqualObjects(expectedOutput, [phoneUtil convertAlphaCharactersInNumber:input], nil);
+ }
+
+
+ #pragma mark - testNormaliseRemovePunctuation
+ {
+ NSString *inputNumber = @"034-56&+#2\u00AD34";
+ NSString *expectedOutput = @"03456234";
+ STAssertEqualObjects(expectedOutput, [phoneUtil normalizePhoneNumber:inputNumber], @"Conversion did not correctly remove punctuation");
+ }
+
+
+ #pragma mark - testNormaliseReplaceAlphaCharacters
+ {
+ NSString *inputNumber = @"034-I-am-HUNGRY";
+ NSString *expectedOutput = @"034426486479";
+ STAssertEqualObjects(expectedOutput, [phoneUtil normalizePhoneNumber:inputNumber], @"Conversion did not correctly replace alpha characters");
+ }
+
+
+ #pragma mark - testNormaliseOtherDigits
+ {
+ NSString *inputNumber = @"\uFF125\u0665";
+ NSString *expectedOutput = @"255";
+ STAssertEqualObjects(expectedOutput, [phoneUtil normalizePhoneNumber:inputNumber], @"Conversion did not correctly replace non-latin digits");
+ // Eastern-Arabic digits.
+ inputNumber = @"\u06F52\u06F0";
+ expectedOutput = @"520";
+ STAssertEqualObjects(expectedOutput, [phoneUtil normalizePhoneNumber:inputNumber], @"Conversion did not correctly replace non-latin digits");
+ }
+
+
+ #pragma mark - testNormaliseStripAlphaCharacters
+ {
+ NSString *inputNumber = @"034-56&+a#234";
+ NSString *expectedOutput = @"03456234";
+ STAssertEqualObjects(expectedOutput, [phoneUtil normalizeDigitsOnly:inputNumber], @"Conversion did not correctly remove alpha character");
+ }
+
+
+ #pragma mark - testFormatUSNumber
+ {
+ STAssertEqualObjects(@"650 253 0000", [phoneUtil format:US_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+1 650 253 0000", [phoneUtil format:US_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"800 253 0000", [phoneUtil format:US_TOLLFREE numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+1 800 253 0000", [phoneUtil format:US_TOLLFREE numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"900 253 0000", [phoneUtil format:US_PREMIUM numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+1 900 253 0000", [phoneUtil format:US_PREMIUM numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"tel:+1-900-253-0000", [phoneUtil format:US_PREMIUM numberFormat:NBEPhoneNumberFormatRFC3966], nil);
+ // Numbers with all zeros in the national number part will be formatted by
+ // using the raw_input if that is available no matter which format is
+ // specified.
+ STAssertEqualObjects(@"000-000-0000", [phoneUtil format:US_SPOOF_WITH_RAW_INPUT numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"0", [phoneUtil format:US_SPOOF numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ }
+
+
+ #pragma mark - testFormatBSNumber
+ {
+ STAssertEqualObjects(@"242 365 1234", [phoneUtil format:BS_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+1 242 365 1234", [phoneUtil format:BS_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ }
+
+
+ #pragma mark - testFormatGBNumber
+ {
+ STAssertEqualObjects(@"(020) 7031 3000", [phoneUtil format:GB_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+44 20 7031 3000", [phoneUtil format:GB_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"(07912) 345 678", [phoneUtil format:GB_MOBILE numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+44 7912 345 678", [phoneUtil format:GB_MOBILE numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ }
+
+
+ #pragma mark - testFormatDENumber
+ {
+ id deNumber = [[NBPhoneNumber alloc] init];
+ [deNumber setCountryCode:@49];
+ [deNumber setNationalNumber:@301234];
+ STAssertEqualObjects(@"030/1234", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+49 30/1234", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"tel:+49-30-1234", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatRFC3966], nil);
+
+ deNumber = [[NBPhoneNumber alloc] init];
+ [deNumber setCountryCode:@49];
+ [deNumber setNationalNumber:@291123];
+ STAssertEqualObjects(@"0291 123", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+49 291 123", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+
+ deNumber = [[NBPhoneNumber alloc] init];
+ [deNumber setCountryCode:@49];
+ [deNumber setNationalNumber:@29112345678];
+ STAssertEqualObjects(@"0291 12345678", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+49 291 12345678", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+
+ deNumber = [[NBPhoneNumber alloc] init];
+ [deNumber setCountryCode:@49];
+ [deNumber setNationalNumber:@912312345];
+ STAssertEqualObjects(@"09123 12345", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+49 9123 12345", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+
+ deNumber = [[NBPhoneNumber alloc] init];
+ [deNumber setCountryCode:@49];
+ [deNumber setNationalNumber:@80212345];
+ STAssertEqualObjects(@"08021 2345", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+49 8021 2345", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+
+ // Note this number is correctly formatted without national prefix. Most of
+ // the numbers that are treated as invalid numbers by the library are short
+ // numbers, and they are usually not dialed with national prefix.
+ STAssertEqualObjects(@"1234", [phoneUtil format:DE_SHORT_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+49 1234", [phoneUtil format:DE_SHORT_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+
+ deNumber = [[NBPhoneNumber alloc] init];
+ [deNumber setCountryCode:@49];
+ [deNumber setNationalNumber:@41341234];
+ STAssertEqualObjects(@"04134 1234", [phoneUtil format:deNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ }
+
+ #pragma mark - testFormatITNumber
+ {
+ STAssertEqualObjects(@"02 3661 8300", [phoneUtil format:IT_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+39 02 3661 8300", [phoneUtil format:IT_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+390236618300", [phoneUtil format:IT_NUMBER numberFormat:NBEPhoneNumberFormatE164], nil);
+ STAssertEqualObjects(@"345 678 901", [phoneUtil format:IT_MOBILE numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+39 345 678 901", [phoneUtil format:IT_MOBILE numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+39345678901", [phoneUtil format:IT_MOBILE numberFormat:NBEPhoneNumberFormatE164], nil);
+ }
+
+ #pragma mark - testFormatAUNumber
+ {
+ STAssertEqualObjects(@"02 3661 8300", [phoneUtil format:AU_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+61 2 3661 8300", [phoneUtil format:AU_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+61236618300", [phoneUtil format:AU_NUMBER numberFormat:NBEPhoneNumberFormatE164], nil);
+
+ id auNumber = [[NBPhoneNumber alloc] init];
+ [auNumber setCountryCode:@61];
+ [auNumber setNationalNumber:@1800123456];
+ STAssertEqualObjects(@"1800 123 456", [phoneUtil format:auNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+61 1800 123 456", [phoneUtil format:auNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+611800123456", [phoneUtil format:auNumber numberFormat:NBEPhoneNumberFormatE164], nil);
+ }
+
+ #pragma mark - testFormatARNumber
+ {
+ STAssertEqualObjects(@"011 8765-4321", [phoneUtil format:AR_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+54 11 8765-4321", [phoneUtil format:AR_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+541187654321", [phoneUtil format:AR_NUMBER numberFormat:NBEPhoneNumberFormatE164], nil);
+ STAssertEqualObjects(@"011 15 8765-4321", [phoneUtil format:AR_MOBILE numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+54 9 11 8765 4321", [phoneUtil format:AR_MOBILE numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+5491187654321", [phoneUtil format:AR_MOBILE numberFormat:NBEPhoneNumberFormatE164], nil);
+ }
+
+ #pragma mark - testFormatMXNumber
+ {
+ STAssertEqualObjects(@"045 234 567 8900", [phoneUtil format:MX_MOBILE1 numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+52 1 234 567 8900", [phoneUtil format:MX_MOBILE1 numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+5212345678900", [phoneUtil format:MX_MOBILE1 numberFormat:NBEPhoneNumberFormatE164], nil);
+ STAssertEqualObjects(@"045 55 1234 5678", [phoneUtil format:MX_MOBILE2 numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+52 1 55 1234 5678", [phoneUtil format:MX_MOBILE2 numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+5215512345678", [phoneUtil format:MX_MOBILE2 numberFormat:NBEPhoneNumberFormatE164], nil);
+ STAssertEqualObjects(@"01 33 1234 5678", [phoneUtil format:MX_NUMBER1 numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+52 33 1234 5678", [phoneUtil format:MX_NUMBER1 numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+523312345678", [phoneUtil format:MX_NUMBER1 numberFormat:NBEPhoneNumberFormatE164], nil);
+ STAssertEqualObjects(@"01 821 123 4567", [phoneUtil format:MX_NUMBER2 numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"+52 821 123 4567", [phoneUtil format:MX_NUMBER2 numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+528211234567", [phoneUtil format:MX_NUMBER2 numberFormat:NBEPhoneNumberFormatE164], nil);
+ }
+
+ #pragma mark - testFormatOutOfCountryCallingNumber
+ {
+ STAssertEqualObjects(@"00 1 900 253 0000", [phoneUtil formatOutOfCountryCallingNumber:US_PREMIUM regionCallingFrom:@"DE"], nil);
+ STAssertEqualObjects(@"1 650 253 0000", [phoneUtil formatOutOfCountryCallingNumber:US_NUMBER regionCallingFrom:@"BS"], nil);
+ STAssertEqualObjects(@"00 1 650 253 0000", [phoneUtil formatOutOfCountryCallingNumber:US_NUMBER regionCallingFrom:@"PL"], nil);
+ STAssertEqualObjects(@"011 44 7912 345 678", [phoneUtil formatOutOfCountryCallingNumber:GB_MOBILE regionCallingFrom:@"US"], nil);
+ STAssertEqualObjects(@"00 49 1234", [phoneUtil formatOutOfCountryCallingNumber:DE_SHORT_NUMBER regionCallingFrom:@"GB"], nil);
+ // Note this number is correctly formatted without national prefix. Most of
+ // the numbers that are treated as invalid numbers by the library are short
+ // numbers, and they are usually not dialed with national prefix.
+ STAssertEqualObjects(@"1234", [phoneUtil formatOutOfCountryCallingNumber:DE_SHORT_NUMBER regionCallingFrom:@"DE"], nil);
+ STAssertEqualObjects(@"011 39 02 3661 8300", [phoneUtil formatOutOfCountryCallingNumber:IT_NUMBER regionCallingFrom:@"US"], nil);
+ STAssertEqualObjects(@"02 3661 8300", [phoneUtil formatOutOfCountryCallingNumber:IT_NUMBER regionCallingFrom:@"IT"], nil);
+ STAssertEqualObjects(@"+39 02 3661 8300", [phoneUtil formatOutOfCountryCallingNumber:IT_NUMBER regionCallingFrom:@"SG"], nil);
+ STAssertEqualObjects(@"6521 8000", [phoneUtil formatOutOfCountryCallingNumber:SG_NUMBER regionCallingFrom:@"SG"], nil);
+ STAssertEqualObjects(@"011 54 9 11 8765 4321", [phoneUtil formatOutOfCountryCallingNumber:AR_MOBILE regionCallingFrom:@"US"], nil);
+ STAssertEqualObjects(@"011 800 1234 5678", [phoneUtil formatOutOfCountryCallingNumber:INTERNATIONAL_TOLL_FREE regionCallingFrom:@"US"], nil);
+
+ id arNumberWithExtn = [AR_MOBILE copy];
+ [arNumberWithExtn setExtension:@"1234"];
+ STAssertEqualObjects(@"011 54 9 11 8765 4321 ext. 1234", [phoneUtil formatOutOfCountryCallingNumber:arNumberWithExtn regionCallingFrom:@"US"], nil);
+ STAssertEqualObjects(@"0011 54 9 11 8765 4321 ext. 1234", [phoneUtil formatOutOfCountryCallingNumber:arNumberWithExtn regionCallingFrom:@"AU"], nil);
+ STAssertEqualObjects(@"011 15 8765-4321 ext. 1234", [phoneUtil formatOutOfCountryCallingNumber:arNumberWithExtn regionCallingFrom:@"AR"], nil);
+ }
+
+
+ #pragma mark - testFormatOutOfCountryWithInvalidRegion
+ {
+ // AQ/Antarctica isn't a valid region code for phone number formatting,
+ // so this falls back to intl formatting.
+ STAssertEqualObjects(@"+1 650 253 0000", [phoneUtil formatOutOfCountryCallingNumber:US_NUMBER regionCallingFrom:@"AQ"], nil);
+ // For region code 001, the out-of-country format always turns into the
+ // international format.
+ STAssertEqualObjects(@"+1 650 253 0000", [phoneUtil formatOutOfCountryCallingNumber:US_NUMBER regionCallingFrom:@"001"], nil);
+ }
+
+
+ #pragma mark - testFormatOutOfCountryWithPreferredIntlPrefix
+ {
+ // This should use 0011, since that is the preferred international prefix
+ // (both 0011 and 0012 are accepted as possible international prefixes in our
+ // test metadta.)
+ STAssertEqualObjects(@"0011 39 02 3661 8300", [phoneUtil formatOutOfCountryCallingNumber:IT_NUMBER regionCallingFrom:@"AU"], nil);
+ }
+
+
+ #pragma mark - testFormatOutOfCountryKeepingAlphaChars
+ {
+ id alphaNumericNumber = [[NBPhoneNumber alloc] init];
+ [alphaNumericNumber setCountryCode:@1];
+ [alphaNumericNumber setNationalNumber:@8007493524];
+ [alphaNumericNumber setRawInput:@"1800 six-flag"];
+ STAssertEqualObjects(@"0011 1 800 SIX-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"AU"], nil);
+
+ [alphaNumericNumber setRawInput:@"1-800-SIX-flag"];
+ STAssertEqualObjects(@"0011 1 800-SIX-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"AU"], nil);
+
+ [alphaNumericNumber setRawInput:@"Call us from UK: 00 1 800 SIX-flag"];
+ STAssertEqualObjects(@"0011 1 800 SIX-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"AU"], nil);
+
+ [alphaNumericNumber setRawInput:@"800 SIX-flag"];
+ STAssertEqualObjects(@"0011 1 800 SIX-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"AU"], nil);
+
+ // Formatting from within the NANPA region.
+ STAssertEqualObjects(@"1 800 SIX-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"US"], nil);
+ STAssertEqualObjects(@"1 800 SIX-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"BS"], nil);
+
+ // Testing that if the raw input doesn't exist, it is formatted using
+ // formatOutOfCountryCallingNumber.
+ [alphaNumericNumber setRawInput:nil];
+ STAssertEqualObjects(@"00 1 800 749 3524", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"DE"], nil);
+
+ // Testing AU alpha number formatted from Australia.
+ [alphaNumericNumber setCountryCode:@61];
+ [alphaNumericNumber setNationalNumber:@827493524];
+ [alphaNumericNumber setRawInput:@"+61 82749-FLAG"];
+ // This number should have the national prefix fixed.
+ STAssertEqualObjects(@"082749-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"AU"], nil);
+
+ [alphaNumericNumber setRawInput:@"082749-FLAG"];
+ STAssertEqualObjects(@"082749-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"AU"], nil);
+
+ [alphaNumericNumber setNationalNumber:@18007493524];
+ [alphaNumericNumber setRawInput:@"1-800-SIX-flag"];
+ // This number should not have the national prefix prefixed, in accordance
+ // with the override for this specific formatting rule.
+ STAssertEqualObjects(@"1-800-SIX-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"AU"], nil);
+
+ // The metadata should not be permanently changed, since we copied it before
+ // modifying patterns. Here we check this.
+ [alphaNumericNumber setNationalNumber:@1800749352];
+ STAssertEqualObjects(@"1800 749 352", [phoneUtil formatOutOfCountryCallingNumber:alphaNumericNumber regionCallingFrom:@"AU"], nil);
+
+ // Testing a region with multiple international prefixes.
+ STAssertEqualObjects(@"+61 1-800-SIX-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"SG"], nil);
+ // Testing the case of calling from a non-supported region.
+ STAssertEqualObjects(@"+61 1-800-SIX-FLAG", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"AQ"], nil);
+
+ // Testing the case with an invalid country calling code.
+ [alphaNumericNumber setCountryCode:@0];
+ [alphaNumericNumber setNationalNumber:@18007493524];
+ [alphaNumericNumber setRawInput:@"1-800-SIX-flag"];
+ // Uses the raw input only.
+ STAssertEqualObjects(@"1-800-SIX-flag", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"DE"], nil);
+
+ // Testing the case of an invalid alpha number.
+ [alphaNumericNumber setCountryCode:@1];
+ [alphaNumericNumber setNationalNumber:@80749];
+ [alphaNumericNumber setRawInput:@"180-SIX"];
+ // No country-code stripping can be done.
+ STAssertEqualObjects(@"00 1 180-SIX", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"DE"], nil);
+
+ // Testing the case of calling from a non-supported region.
+ [alphaNumericNumber setCountryCode:@1];
+ [alphaNumericNumber setNationalNumber:@80749];
+ [alphaNumericNumber setRawInput:@"180-SIX"];
+ // No country-code stripping can be done since the number is invalid.
+ STAssertEqualObjects(@"+1 180-SIX", [phoneUtil formatOutOfCountryKeepingAlphaChars:alphaNumericNumber regionCallingFrom:@"AQ"], nil);
+ }
+
+
+ #pragma mark - testFormatWithCarrierCode()
+ {
+ // We only support this for AR in our test metadata, and only for mobile
+ // numbers starting with certain values.
+
+ NBPhoneNumber *arMobile = [[NBPhoneNumber alloc] init];
+ [arMobile setCountryCode:@54];
+ [arMobile setNationalNumber:@92234654321];
+ STAssertEqualObjects(@"02234 65-4321", [phoneUtil format:arMobile numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ // Here we force 14 as the carrier code.
+ STAssertEqualObjects(@"02234 14 65-4321", [phoneUtil formatNationalNumberWithCarrierCode:arMobile carrierCode:@"14"], nil);
+ // Here we force the number to be shown with no carrier code.
+ STAssertEqualObjects(@"02234 65-4321", [phoneUtil formatNationalNumberWithCarrierCode:arMobile carrierCode:@""], nil);
+ // Here the international rule is used, so no carrier code should be present.
+ STAssertEqualObjects(@"+5492234654321", [phoneUtil format:arMobile numberFormat:NBEPhoneNumberFormatE164], nil);
+ // We don't support this for the US so there should be no change.
+ STAssertEqualObjects(@"650 253 0000", [phoneUtil formatNationalNumberWithCarrierCode:US_NUMBER carrierCode:@"15"], nil);
+ // Invalid country code should just get the NSN.
+ STAssertEqualObjects(@"12345", [phoneUtil formatNationalNumberWithCarrierCode:UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT carrierCode:@"89"], nil);
+ }
+
+
+ #pragma mark - testFormatWithPreferredCarrierCode
+ {
+ // We only support this for AR in our test metadata.
+
+ NBPhoneNumber *arNumber = [[NBPhoneNumber alloc] init];
+ [arNumber setCountryCode:@54];
+ [arNumber setNationalNumber:@91234125678];
+ // Test formatting with no preferred carrier code stored in the number itself.
+ STAssertEqualObjects(@"01234 15 12-5678", [phoneUtil formatNationalNumberWithPreferredCarrierCode:arNumber fallbackCarrierCode:@"15"], nil);
+ STAssertEqualObjects(@"01234 12-5678", [phoneUtil formatNationalNumberWithPreferredCarrierCode:arNumber fallbackCarrierCode:@""], nil);
+ // Test formatting with preferred carrier code present.
+ [arNumber setPreferredDomesticCarrierCode:@"19"];
+ STAssertEqualObjects(@"01234 12-5678", [phoneUtil format:arNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"01234 19 12-5678", [phoneUtil formatNationalNumberWithPreferredCarrierCode:arNumber fallbackCarrierCode:@"15"], nil);
+ STAssertEqualObjects(@"01234 19 12-5678", [phoneUtil formatNationalNumberWithPreferredCarrierCode:arNumber fallbackCarrierCode:@""], nil);
+ // When the preferred_domestic_carrier_code is present (even when it contains
+ // an empty string), use it instead of the default carrier code passed in.
+ [arNumber setPreferredDomesticCarrierCode:@""];
+ STAssertEqualObjects(@"01234 12-5678", [phoneUtil formatNationalNumberWithPreferredCarrierCode:arNumber fallbackCarrierCode:@"15"], nil);
+ // We don't support this for the US so there should be no change.
+
+ NBPhoneNumber *usNumber = [[NBPhoneNumber alloc] init];
+ [usNumber setCountryCode:@1];
+ [usNumber setNationalNumber:@4241231234];
+ [usNumber setPreferredDomesticCarrierCode:@"99"];
+ STAssertEqualObjects(@"424 123 1234", [phoneUtil format:usNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEqualObjects(@"424 123 1234", [phoneUtil formatNationalNumberWithPreferredCarrierCode:usNumber fallbackCarrierCode:@"15"], nil);
+ }
+
+
+ #pragma mark - testFormatNumberForMobileDialing
+ {
+ // Numbers are normally dialed in national format in-country, and
+ // international format from outside the country.
+ STAssertEqualObjects(@"030123456", [phoneUtil formatNumberForMobileDialing:DE_NUMBER regionCallingFrom:@"DE" withFormatting:NO], nil);
+ STAssertEqualObjects(@"+4930123456", [phoneUtil formatNumberForMobileDialing:DE_NUMBER regionCallingFrom:@"CH" withFormatting:NO], nil);
+ id deNumberWithExtn = [DE_NUMBER copy];
+ [deNumberWithExtn setExtension:@"1234"];
+ STAssertEqualObjects(@"030123456", [phoneUtil formatNumberForMobileDialing:deNumberWithExtn regionCallingFrom:@"DE" withFormatting:NO], nil);
+ STAssertEqualObjects(@"+4930123456", [phoneUtil formatNumberForMobileDialing:deNumberWithExtn regionCallingFrom:@"CH" withFormatting:NO], nil);
+
+ // US toll free numbers are marked as noInternationalDialling in the test
+ // metadata for testing purposes.
+ STAssertEqualObjects(@"800 253 0000", [phoneUtil formatNumberForMobileDialing:US_TOLLFREE regionCallingFrom:@"US" withFormatting:YES], nil);
+ STAssertEqualObjects(@"", [phoneUtil formatNumberForMobileDialing:US_TOLLFREE regionCallingFrom:@"CN" withFormatting:YES], nil);
+ STAssertEqualObjects(@"+1 650 253 0000", [phoneUtil formatNumberForMobileDialing:US_NUMBER regionCallingFrom:@"US" withFormatting:YES], nil);
+
+ id usNumberWithExtn = [US_NUMBER copy];
+ [usNumberWithExtn setExtension:@"1234"];
+ STAssertEqualObjects(@"+1 650 253 0000", [phoneUtil formatNumberForMobileDialing:usNumberWithExtn regionCallingFrom:@"US" withFormatting:YES], nil);
+ STAssertEqualObjects(@"8002530000", [phoneUtil formatNumberForMobileDialing:US_TOLLFREE regionCallingFrom:@"US" withFormatting:NO], nil);
+ STAssertEqualObjects(@"", [phoneUtil formatNumberForMobileDialing:US_TOLLFREE regionCallingFrom:@"CN" withFormatting:NO], nil);
+ STAssertEqualObjects(@"+16502530000", [phoneUtil formatNumberForMobileDialing:US_NUMBER regionCallingFrom:@"US" withFormatting:NO], nil);
+ STAssertEqualObjects(@"+16502530000", [phoneUtil formatNumberForMobileDialing:usNumberWithExtn regionCallingFrom:@"US" withFormatting:NO], nil);
+
+ // An invalid US number, which is one digit too long.
+ STAssertEqualObjects(@"+165025300001", [phoneUtil formatNumberForMobileDialing:US_LONG_NUMBER regionCallingFrom:@"US" withFormatting:NO], nil);
+ STAssertEqualObjects(@"+1 65025300001", [phoneUtil formatNumberForMobileDialing:US_LONG_NUMBER regionCallingFrom:@"US" withFormatting:YES], nil);
+
+ // Star numbers. In real life they appear in Israel, but we have them in JP
+ // in our test metadata.
+ STAssertEqualObjects(@"*2345", [phoneUtil formatNumberForMobileDialing:JP_STAR_NUMBER regionCallingFrom:@"JP" withFormatting:NO], nil);
+ STAssertEqualObjects(@"*2345", [phoneUtil formatNumberForMobileDialing:JP_STAR_NUMBER regionCallingFrom:@"JP" withFormatting:YES], nil);
+ STAssertEqualObjects(@"+80012345678", [phoneUtil formatNumberForMobileDialing:INTERNATIONAL_TOLL_FREE regionCallingFrom:@"JP" withFormatting:NO], nil);
+ STAssertEqualObjects(@"+800 1234 5678", [phoneUtil formatNumberForMobileDialing:INTERNATIONAL_TOLL_FREE regionCallingFrom:@"JP" withFormatting:YES], nil);
+
+ // UAE numbers beginning with 600 (classified as UAN) need to be dialled
+ // without +971 locally.
+ STAssertEqualObjects(@"+971600123456", [phoneUtil formatNumberForMobileDialing:AE_UAN regionCallingFrom:@"JP" withFormatting:NO], nil);
+ STAssertEqualObjects(@"600123456", [phoneUtil formatNumberForMobileDialing:AE_UAN regionCallingFrom:@"AE" withFormatting:NO], nil);
+ STAssertEqualObjects(@"+523312345678",
+ [phoneUtil formatNumberForMobileDialing:MX_NUMBER1 regionCallingFrom:@"MX" withFormatting:NO], nil);
+ STAssertEqualObjects(@"+523312345678",
+ [phoneUtil formatNumberForMobileDialing:MX_NUMBER1 regionCallingFrom:@"US" withFormatting:NO], nil);
+
+ // Non-geographical numbers should always be dialed in international format.
+ STAssertEqualObjects(@"+80012345678", [phoneUtil formatNumberForMobileDialing:INTERNATIONAL_TOLL_FREE regionCallingFrom:@"US" withFormatting:NO], nil);
+ STAssertEqualObjects(@"+80012345678", [phoneUtil formatNumberForMobileDialing:INTERNATIONAL_TOLL_FREE regionCallingFrom:@"UN001" withFormatting:NO], nil);
+
+ }
+
+
+ #pragma mark - testFormatByPattern
+ {
+ NBNumberFormat *newNumFormat = [[NBNumberFormat alloc] init];
+ [newNumFormat setPattern:@"(\\d{3})(\\d{3})(\\d{4})"];
+ [newNumFormat setFormat:@"($1) $2-$3"];
+
+ STAssertEqualObjects(@"(650) 253-0000", [phoneUtil formatByPattern:US_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL userDefinedFormats:@[newNumFormat]], nil);
+
+ STAssertEqualObjects(@"+1 (650) 253-0000", [phoneUtil formatByPattern:US_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL userDefinedFormats:@[newNumFormat]], nil);
+ STAssertEqualObjects(@"tel:+1-650-253-0000", [phoneUtil formatByPattern:US_NUMBER numberFormat:NBEPhoneNumberFormatRFC3966 userDefinedFormats:@[newNumFormat]], nil);
+
+ // $NP is set to '1' for the US. Here we check that for other NANPA countries
+ // the US rules are followed.
+ [newNumFormat setNationalPrefixFormattingRule:@"$NP ($FG)"];
+ [newNumFormat setFormat:@"$1 $2-$3"];
+ STAssertEqualObjects(@"1 (242) 365-1234", [phoneUtil formatByPattern:BS_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL userDefinedFormats:@[newNumFormat]], nil);
+ STAssertEqualObjects(@"+1 242 365-1234", [phoneUtil formatByPattern:BS_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL userDefinedFormats:@[newNumFormat]], nil);
+
+ [newNumFormat setPattern:@"(\\d{2})(\\d{5})(\\d{3})"];
+ [newNumFormat setFormat:@"$1-$2 $3"];
+
+ STAssertEqualObjects(@"02-36618 300", [phoneUtil formatByPattern:IT_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL userDefinedFormats:@[newNumFormat]], nil);
+ STAssertEqualObjects(@"+39 02-36618 300", [phoneUtil formatByPattern:IT_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL userDefinedFormats:@[newNumFormat]], nil);
+
+ [newNumFormat setNationalPrefixFormattingRule:@"$NP$FG"];
+ [newNumFormat setPattern:@"(\\d{2})(\\d{4})(\\d{4})"];
+ [newNumFormat setFormat:@"$1 $2 $3"];
+ STAssertEqualObjects(@"020 7031 3000", [phoneUtil formatByPattern:GB_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL userDefinedFormats:@[newNumFormat]], nil);
+
+ [newNumFormat setNationalPrefixFormattingRule:@"($NP$FG)"];
+ STAssertEqualObjects(@"(020) 7031 3000", [phoneUtil formatByPattern:GB_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL userDefinedFormats:@[newNumFormat]], nil);
+
+ [newNumFormat setNationalPrefixFormattingRule:@""];
+ STAssertEqualObjects(@"20 7031 3000", [phoneUtil formatByPattern:GB_NUMBER numberFormat:NBEPhoneNumberFormatNATIONAL userDefinedFormats:@[newNumFormat]], nil);
+ STAssertEqualObjects(@"+44 20 7031 3000", [phoneUtil formatByPattern:GB_NUMBER numberFormat:NBEPhoneNumberFormatINTERNATIONAL userDefinedFormats:@[newNumFormat]], nil);
+ }
+
+
+ #pragma mark - testFormatE164Number
+ {
+ STAssertEqualObjects(@"+16502530000", [phoneUtil format:US_NUMBER numberFormat:NBEPhoneNumberFormatE164], nil);
+ STAssertEqualObjects(@"+4930123456", [phoneUtil format:DE_NUMBER numberFormat:NBEPhoneNumberFormatE164], nil);
+ STAssertEqualObjects(@"+80012345678", [phoneUtil format:INTERNATIONAL_TOLL_FREE numberFormat:NBEPhoneNumberFormatE164], nil);
+ }
+
+
+ #pragma mark - testFormatNumberWithExtension
+ {
+ id nzNumber = [NZ_NUMBER copy];
+ [nzNumber setExtension:@"1234"];
+ // Uses default extension prefix:
+ STAssertEqualObjects(@"03-331 6005 ext. 1234", [phoneUtil format:nzNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ // Uses RFC 3966 syntax.
+ STAssertEqualObjects(@"tel:+64-3-331-6005;ext=1234", [phoneUtil format:nzNumber numberFormat:NBEPhoneNumberFormatRFC3966], nil);
+ // Extension prefix overridden in the territory information for the US:
+
+ id usNumberWithExtension = [US_NUMBER copy];
+ [usNumberWithExtension setExtension:@"4567"];
+ STAssertEqualObjects(@"650 253 0000 extn. 4567", [phoneUtil format:usNumberWithExtension numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ }
+
+
+ #pragma mark - testFormatInOriginalFormat
+ {
+ NBPhoneNumber *number1 = [phoneUtil parseAndKeepRawInput:@"+442087654321" defaultRegion:@"GB"];
+ STAssertEqualObjects(@"+44 20 8765 4321", [phoneUtil formatInOriginalFormat:number1 regionCallingFrom:@"GB"], nil);
+
+ NBPhoneNumber *number2 = [phoneUtil parseAndKeepRawInput:@"02087654321" defaultRegion:@"GB"];
+ STAssertEqualObjects(@"(020) 8765 4321", [phoneUtil formatInOriginalFormat:number2 regionCallingFrom:@"GB"], nil);
+
+ NBPhoneNumber *number3 = [phoneUtil parseAndKeepRawInput:@"011442087654321" defaultRegion:@"US"];
+ STAssertEqualObjects(@"011 44 20 8765 4321", [phoneUtil formatInOriginalFormat:number3 regionCallingFrom:@"US"], nil);
+
+ NBPhoneNumber *number4 = [phoneUtil parseAndKeepRawInput:@"442087654321" defaultRegion:@"GB"];
+ STAssertEqualObjects(@"44 20 8765 4321", [phoneUtil formatInOriginalFormat:number4 regionCallingFrom:@"GB"], nil);
+
+ NBPhoneNumber *number5 = [phoneUtil parse:@"+442087654321" defaultRegion:@"GB"];
+ STAssertEqualObjects(@"(020) 8765 4321", [phoneUtil formatInOriginalFormat:number5 regionCallingFrom:@"GB"], nil);
+
+ // Invalid numbers that we have a formatting pattern for should be formatted
+ // properly. Note area codes starting with 7 are intentionally excluded in
+ // the test metadata for testing purposes.
+ NBPhoneNumber *number6 = [phoneUtil parseAndKeepRawInput:@"7345678901" defaultRegion:@"US"];
+ STAssertEqualObjects(@"734 567 8901", [phoneUtil formatInOriginalFormat:number6 regionCallingFrom:@"US"], nil);
+
+ // US is not a leading zero country, and the presence of the leading zero
+ // leads us to format the number using raw_input.
+ NBPhoneNumber *number7 = [phoneUtil parseAndKeepRawInput:@"0734567 8901" defaultRegion:@"US"];
+ STAssertEqualObjects(@"0734567 8901", [phoneUtil formatInOriginalFormat:number7 regionCallingFrom:@"US"], nil);
+
+ // This number is valid, but we don't have a formatting pattern for it.
+ // Fall back to the raw input.
+ NBPhoneNumber *number8 = [phoneUtil parseAndKeepRawInput:@"02-4567-8900" defaultRegion:@"KR"];
+ STAssertEqualObjects(@"02-4567-8900", [phoneUtil formatInOriginalFormat:number8 regionCallingFrom:@"KR"], nil);
+
+ NBPhoneNumber *number9 = [phoneUtil parseAndKeepRawInput:@"01180012345678" defaultRegion:@"US"];
+ STAssertEqualObjects(@"011 800 1234 5678", [phoneUtil formatInOriginalFormat:number9 regionCallingFrom:@"US"], nil);
+
+ NBPhoneNumber *number10 = [phoneUtil parseAndKeepRawInput:@"+80012345678" defaultRegion:@"KR"];
+ STAssertEqualObjects(@"+800 1234 5678", [phoneUtil formatInOriginalFormat:number10 regionCallingFrom:@"KR"], nil);
+
+ // US local numbers are formatted correctly, as we have formatting patterns
+ // for them.
+ NBPhoneNumber *localNumberUS = [phoneUtil parseAndKeepRawInput:@"2530000" defaultRegion:@"US"];
+ STAssertEqualObjects(@"253 0000", [phoneUtil formatInOriginalFormat:localNumberUS regionCallingFrom:@"US"], nil);
+
+ NBPhoneNumber *numberWithNationalPrefixUS = [phoneUtil parseAndKeepRawInput:@"18003456789" defaultRegion:@"US"];
+ STAssertEqualObjects(@"1 800 345 6789", [phoneUtil formatInOriginalFormat:numberWithNationalPrefixUS regionCallingFrom:@"US"], nil);
+
+ NBPhoneNumber *numberWithoutNationalPrefixGB = [phoneUtil parseAndKeepRawInput:@"2087654321" defaultRegion:@"GB"];
+ STAssertEqualObjects(@"20 8765 4321", [phoneUtil formatInOriginalFormat:numberWithoutNationalPrefixGB regionCallingFrom:@"GB"], nil);
+
+ // Make sure no metadata is modified as a result of the previous function
+ // call.
+ STAssertEqualObjects(@"(020) 8765 4321", [phoneUtil formatInOriginalFormat:number5 regionCallingFrom:@"GB"], nil);
+
+ NBPhoneNumber *numberWithNationalPrefixMX = [phoneUtil parseAndKeepRawInput:@"013312345678" defaultRegion:@"MX"];
+ STAssertEqualObjects(@"01 33 1234 5678", [phoneUtil formatInOriginalFormat:numberWithNationalPrefixMX regionCallingFrom:@"MX"], nil);
+
+ NBPhoneNumber *numberWithoutNationalPrefixMX = [phoneUtil parseAndKeepRawInput:@"3312345678" defaultRegion:@"MX"];
+ STAssertEqualObjects(@"33 1234 5678", [phoneUtil formatInOriginalFormat:numberWithoutNationalPrefixMX regionCallingFrom:@"MX"], nil);
+
+ NBPhoneNumber *italianFixedLineNumber = [phoneUtil parseAndKeepRawInput:@"0212345678" defaultRegion:@"IT"];
+ STAssertEqualObjects(@"02 1234 5678", [phoneUtil formatInOriginalFormat:italianFixedLineNumber regionCallingFrom:@"IT"], nil);
+
+ NBPhoneNumber *numberWithNationalPrefixJP = [phoneUtil parseAndKeepRawInput:@"00777012" defaultRegion:@"JP"];
+ STAssertEqualObjects(@"0077-7012", [phoneUtil formatInOriginalFormat:numberWithNationalPrefixJP regionCallingFrom:@"JP"], nil);
+
+ NBPhoneNumber *numberWithoutNationalPrefixJP = [phoneUtil parseAndKeepRawInput:@"0777012" defaultRegion:@"JP"];
+ STAssertEqualObjects(@"0777012", [phoneUtil formatInOriginalFormat:numberWithoutNationalPrefixJP regionCallingFrom:@"JP"], nil);
+
+ NBPhoneNumber *numberWithCarrierCodeBR = [phoneUtil parseAndKeepRawInput:@"012 3121286979" defaultRegion:@"BR"];
+ STAssertEqualObjects(@"012 3121286979", [phoneUtil formatInOriginalFormat:numberWithCarrierCodeBR regionCallingFrom:@"BR"], nil);
+
+ // The default national prefix used in this case is 045. When a number with
+ // national prefix 044 is entered, we return the raw input as we don't want to
+ // change the number entered.
+ NBPhoneNumber *numberWithNationalPrefixMX1 = [phoneUtil parseAndKeepRawInput:@"044(33)1234-5678" defaultRegion:@"MX"];
+ STAssertEqualObjects(@"044(33)1234-5678", [phoneUtil formatInOriginalFormat:numberWithNationalPrefixMX1 regionCallingFrom:@"MX"], nil);
+
+ NBPhoneNumber *numberWithNationalPrefixMX2 = [phoneUtil parseAndKeepRawInput:@"045(33)1234-5678" defaultRegion:@"MX"];
+ STAssertEqualObjects(@"045 33 1234 5678", [phoneUtil formatInOriginalFormat:numberWithNationalPrefixMX2 regionCallingFrom:@"MX"], nil);
+
+ // The default international prefix used in this case is 0011. When a number
+ // with international prefix 0012 is entered, we return the raw input as we
+ // don't want to change the number entered.
+ id outOfCountryNumberFromAU1 = [phoneUtil parseAndKeepRawInput:@"0012 16502530000" defaultRegion:@"AU"];
+ STAssertEqualObjects(@"0012 16502530000", [phoneUtil formatInOriginalFormat:outOfCountryNumberFromAU1 regionCallingFrom:@"AU"], nil);
+
+ id outOfCountryNumberFromAU2 = [phoneUtil parseAndKeepRawInput:@"0011 16502530000" defaultRegion:@"AU"];
+ STAssertEqualObjects(@"0011 1 650 253 0000", [phoneUtil formatInOriginalFormat:outOfCountryNumberFromAU2 regionCallingFrom:@"AU"], nil);
+
+ // Test the star sign is not removed from or added to the original input by
+ // this method.
+ id starNumber = [phoneUtil parseAndKeepRawInput:@"*1234" defaultRegion:@"JP"];
+ STAssertEqualObjects(@"*1234", [phoneUtil formatInOriginalFormat:starNumber regionCallingFrom:@"JP"], nil);
+
+ NBPhoneNumber *numberWithoutStar = [phoneUtil parseAndKeepRawInput:@"1234" defaultRegion:@"JP"];
+ STAssertEqualObjects(@"1234", [phoneUtil formatInOriginalFormat:numberWithoutStar regionCallingFrom:@"JP"], nil);
+
+ // Test an invalid national number without raw input is just formatted as the
+ // national number.
+ STAssertEqualObjects(@"650253000", [phoneUtil formatInOriginalFormat:US_SHORT_BY_ONE_NUMBER regionCallingFrom:@"US"], nil);
+ }
+
+ #pragma mark - testIsPremiumRate
+ {
+ STAssertEquals(NBEPhoneNumberTypePREMIUM_RATE, [phoneUtil getNumberType:US_PREMIUM], nil);
+
+ NBPhoneNumber *premiumRateNumber = [[NBPhoneNumber alloc] init];
+ premiumRateNumber = [[NBPhoneNumber alloc] init];
+ [premiumRateNumber setCountryCode:@39];
+ [premiumRateNumber setNationalNumber:@892123];
+ STAssertEquals(NBEPhoneNumberTypePREMIUM_RATE, [phoneUtil getNumberType:premiumRateNumber], nil);
+
+ premiumRateNumber = [[NBPhoneNumber alloc] init];
+ [premiumRateNumber setCountryCode:@44];
+ [premiumRateNumber setNationalNumber:@9187654321];
+ STAssertEquals(NBEPhoneNumberTypePREMIUM_RATE, [phoneUtil getNumberType:premiumRateNumber], nil);
+
+ premiumRateNumber = [[NBPhoneNumber alloc] init];
+ [premiumRateNumber setCountryCode:@49];
+ [premiumRateNumber setNationalNumber:@9001654321];
+ STAssertEquals(NBEPhoneNumberTypePREMIUM_RATE, [phoneUtil getNumberType:premiumRateNumber], nil);
+
+ premiumRateNumber = [[NBPhoneNumber alloc] init];
+ [premiumRateNumber setCountryCode:@49];
+ [premiumRateNumber setNationalNumber:@90091234567];
+ STAssertEquals(NBEPhoneNumberTypePREMIUM_RATE, [phoneUtil getNumberType:premiumRateNumber], nil);
+ STAssertEquals(NBEPhoneNumberTypePREMIUM_RATE, [phoneUtil getNumberType:UNIVERSAL_PREMIUM_RATE], nil);
+ }
+
+
+ #pragma mark - testIsTollFree
+ {
+ NBPhoneNumber *tollFreeNumber = [[NBPhoneNumber alloc] init];
+
+ [tollFreeNumber setCountryCode:@1];
+ [tollFreeNumber setNationalNumber:@8881234567];
+ STAssertEquals(NBEPhoneNumberTypeTOLL_FREE, [phoneUtil getNumberType:tollFreeNumber], nil);
+
+ tollFreeNumber = [[NBPhoneNumber alloc] init];
+ [tollFreeNumber setCountryCode:@39];
+ [tollFreeNumber setNationalNumber:@803123];
+ STAssertEquals(NBEPhoneNumberTypeTOLL_FREE, [phoneUtil getNumberType:tollFreeNumber], nil);
+
+ tollFreeNumber = [[NBPhoneNumber alloc] init];
+ [tollFreeNumber setCountryCode:@44];
+ [tollFreeNumber setNationalNumber:@8012345678];
+ STAssertEquals(NBEPhoneNumberTypeTOLL_FREE, [phoneUtil getNumberType:tollFreeNumber], nil);
+
+ tollFreeNumber = [[NBPhoneNumber alloc] init];
+ [tollFreeNumber setCountryCode:@49];
+ [tollFreeNumber setNationalNumber:@8001234567];
+ STAssertEquals(NBEPhoneNumberTypeTOLL_FREE, [phoneUtil getNumberType:tollFreeNumber], nil);
+
+ STAssertEquals(NBEPhoneNumberTypeTOLL_FREE, [phoneUtil getNumberType:INTERNATIONAL_TOLL_FREE], nil);
+ }
+
+
+ #pragma mark - testIsMobile
+ {
+ STAssertEquals(NBEPhoneNumberTypeMOBILE, [phoneUtil getNumberType:BS_MOBILE], nil);
+ STAssertEquals(NBEPhoneNumberTypeMOBILE, [phoneUtil getNumberType:GB_MOBILE], nil);
+ STAssertEquals(NBEPhoneNumberTypeMOBILE, [phoneUtil getNumberType:IT_MOBILE], nil);
+ STAssertEquals(NBEPhoneNumberTypeMOBILE, [phoneUtil getNumberType:AR_MOBILE], nil);
+
+ NBPhoneNumber *mobileNumber = [[NBPhoneNumber alloc] init];
+ [mobileNumber setCountryCode:@49];
+ [mobileNumber setNationalNumber:@15123456789];
+ STAssertEquals(NBEPhoneNumberTypeMOBILE, [phoneUtil getNumberType:mobileNumber], nil);
+ }
+
+
+ #pragma mark - testIsFixedLine
+ {
+ STAssertEquals(NBEPhoneNumberTypeFIXED_LINE, [phoneUtil getNumberType:BS_NUMBER], nil);
+ STAssertEquals(NBEPhoneNumberTypeFIXED_LINE, [phoneUtil getNumberType:IT_NUMBER], nil);
+ STAssertEquals(NBEPhoneNumberTypeFIXED_LINE, [phoneUtil getNumberType:GB_NUMBER], nil);
+ STAssertEquals(NBEPhoneNumberTypeFIXED_LINE, [phoneUtil getNumberType:DE_NUMBER], nil);
+ }
+
+
+ #pragma mark - testIsFixedLineAndMobile
+ {
+ STAssertEquals(NBEPhoneNumberTypeFIXED_LINE_OR_MOBILE, [phoneUtil getNumberType:US_NUMBER], nil);
+
+ NBPhoneNumber *fixedLineAndMobileNumber = [[NBPhoneNumber alloc] init];
+ [fixedLineAndMobileNumber setCountryCode:@54];
+ [fixedLineAndMobileNumber setNationalNumber:@1987654321];
+ STAssertEquals(NBEPhoneNumberTypeFIXED_LINE_OR_MOBILE, [phoneUtil getNumberType:fixedLineAndMobileNumber], nil);
+ }
+
+
+ #pragma mark - testIsSharedCost
+ {
+ NBPhoneNumber *gbNumber = [[NBPhoneNumber alloc] init];
+ [gbNumber setCountryCode:@44];
+ [gbNumber setNationalNumber:@8431231234];
+ STAssertEquals(NBEPhoneNumberTypeSHARED_COST, [phoneUtil getNumberType:gbNumber], nil);
+ }
+
+
+ #pragma mark - testIsVoip
+ {
+ NBPhoneNumber *gbNumber = [[NBPhoneNumber alloc] init];
+ [gbNumber setCountryCode:@44];
+ [gbNumber setNationalNumber:@5631231234];
+ STAssertEquals(NBEPhoneNumberTypeVOIP, [phoneUtil getNumberType:gbNumber], nil);
+ }
+
+
+ #pragma mark - testIsPersonalNumber
+ {
+ NBPhoneNumber *gbNumber = [[NBPhoneNumber alloc] init];
+ [gbNumber setCountryCode:@44];
+ [gbNumber setNationalNumber:@7031231234];
+ STAssertEquals(NBEPhoneNumberTypePERSONAL_NUMBER, [phoneUtil getNumberType:gbNumber], nil);
+ }
+
+
+ #pragma mark - testIsUnknown
+ {
+ // Invalid numbers should be of type UNKNOWN.
+ STAssertEquals(NBEPhoneNumberTypeUNKNOWN, [phoneUtil getNumberType:US_LOCAL_NUMBER], nil);
+ }
+
+
+ #pragma mark - testisValidNumber
+ {
+ STAssertTrue([phoneUtil isValidNumber:US_NUMBER], nil);
+ STAssertTrue([phoneUtil isValidNumber:IT_NUMBER], nil);
+ STAssertTrue([phoneUtil isValidNumber:GB_MOBILE], nil);
+ STAssertTrue([phoneUtil isValidNumber:INTERNATIONAL_TOLL_FREE], nil);
+ STAssertTrue([phoneUtil isValidNumber:UNIVERSAL_PREMIUM_RATE], nil);
+
+ NBPhoneNumber *nzNumber = [[NBPhoneNumber alloc] init];
+ [nzNumber setCountryCode:@64];
+ [nzNumber setNationalNumber:@21387835];
+ STAssertTrue([phoneUtil isValidNumber:nzNumber], nil);
+ }
+
+
+ #pragma mark - testIsValidForRegion
+ {
+ // This number is valid for the Bahamas, but is not a valid US number.
+ STAssertTrue([phoneUtil isValidNumber:BS_NUMBER], nil);
+ STAssertTrue([phoneUtil isValidNumberForRegion:BS_NUMBER regionCode:@"BS"], nil);
+ STAssertFalse([phoneUtil isValidNumberForRegion:BS_NUMBER regionCode:@"US"], nil);
+
+ NBPhoneNumber *bsInvalidNumber = [[NBPhoneNumber alloc] init];
+ [bsInvalidNumber setCountryCode:@1];
+ [bsInvalidNumber setNationalNumber:@2421232345];
+ // This number is no longer valid.
+ STAssertFalse([phoneUtil isValidNumber:bsInvalidNumber], nil);
+
+ // La Mayotte and Reunion use 'leadingDigits' to differentiate them.
+
+ NBPhoneNumber *reNumber = [[NBPhoneNumber alloc] init];
+ [reNumber setCountryCode:@262];
+ [reNumber setNationalNumber:@262123456];
+ STAssertTrue([phoneUtil isValidNumber:reNumber], nil);
+ STAssertTrue([phoneUtil isValidNumberForRegion:reNumber regionCode:@"RE"], nil);
+ STAssertFalse([phoneUtil isValidNumberForRegion:reNumber regionCode:@"YT"], nil);
+
+ // Now change the number to be a number for La Mayotte.
+ [reNumber setNationalNumber:@269601234];
+ STAssertTrue([phoneUtil isValidNumberForRegion:reNumber regionCode:@"YT"], nil);
+ STAssertFalse([phoneUtil isValidNumberForRegion:reNumber regionCode:@"RE"], nil);
+
+ // This number is no longer valid for La Reunion.
+ [reNumber setNationalNumber:@269123456];
+ STAssertFalse([phoneUtil isValidNumberForRegion:reNumber regionCode:@"YT"], nil);
+ STAssertFalse([phoneUtil isValidNumberForRegion:reNumber regionCode:@"RE"], nil);
+ STAssertFalse([phoneUtil isValidNumber:reNumber], nil);
+
+ // However, it should be recognised as from La Mayotte, since it is valid for
+ // this region.
+ STAssertEqualObjects(@"YT", [phoneUtil getRegionCodeForNumber:reNumber], nil);
+
+ // This number is valid in both places.
+ [reNumber setNationalNumber:@800123456];
+ STAssertTrue([phoneUtil isValidNumberForRegion:reNumber regionCode:@"YT"], nil);
+ STAssertTrue([phoneUtil isValidNumberForRegion:reNumber regionCode:@"RE"], nil);
+ STAssertTrue([phoneUtil isValidNumberForRegion:INTERNATIONAL_TOLL_FREE regionCode:@"001"], nil);
+ STAssertFalse([phoneUtil isValidNumberForRegion:INTERNATIONAL_TOLL_FREE regionCode:@"US"], nil);
+ STAssertFalse([phoneUtil isValidNumberForRegion:INTERNATIONAL_TOLL_FREE regionCode:@"ZZ"], nil);
+
+ NBPhoneNumber *invalidNumber = [[NBPhoneNumber alloc] init];
+ // Invalid country calling codes.
+ [invalidNumber setCountryCode:@3923];
+ [invalidNumber setNationalNumber:@2366];
+ STAssertFalse([phoneUtil isValidNumberForRegion:invalidNumber regionCode:@"ZZ"], nil);
+ STAssertFalse([phoneUtil isValidNumberForRegion:invalidNumber regionCode:@"001"], nil);
+ [invalidNumber setCountryCode:@0];
+ STAssertFalse([phoneUtil isValidNumberForRegion:invalidNumber regionCode:@"001"], nil);
+ STAssertFalse([phoneUtil isValidNumberForRegion:invalidNumber regionCode:@"ZZ"], nil);
+ }
+
+
+ #pragma mark - testIsNotValidNumber
+ {
+ STAssertFalse([phoneUtil isValidNumber:US_LOCAL_NUMBER], nil);
+
+ NBPhoneNumber *invalidNumber = [[NBPhoneNumber alloc] init];
+ [invalidNumber setCountryCode:@39];
+ [invalidNumber setNationalNumber:@23661830000];
+ [invalidNumber setItalianLeadingZero:YES];
+ STAssertFalse([phoneUtil isValidNumber:invalidNumber], nil);
+
+ invalidNumber = [[NBPhoneNumber alloc] init];
+ [invalidNumber setCountryCode:@44];
+ [invalidNumber setNationalNumber:@791234567];
+ STAssertFalse([phoneUtil isValidNumber:invalidNumber], nil);
+
+ invalidNumber = [[NBPhoneNumber alloc] init];
+ [invalidNumber setCountryCode:@0];
+ [invalidNumber setNationalNumber:@1234];
+ STAssertFalse([phoneUtil isValidNumber:invalidNumber], nil);
+
+ invalidNumber = [[NBPhoneNumber alloc] init];
+ [invalidNumber setCountryCode:@64];
+ [invalidNumber setNationalNumber:@3316005];
+ STAssertFalse([phoneUtil isValidNumber:invalidNumber], nil);
+
+ invalidNumber = [[NBPhoneNumber alloc] init];
+ // Invalid country calling codes.
+ [invalidNumber setCountryCode:@3923];
+ [invalidNumber setNationalNumber:@2366];
+ STAssertFalse([phoneUtil isValidNumber:invalidNumber], nil);
+ [invalidNumber setCountryCode:@0];
+ STAssertFalse([phoneUtil isValidNumber:invalidNumber], nil);
+
+ STAssertFalse([phoneUtil isValidNumber:INTERNATIONAL_TOLL_FREE_TOO_LONG], nil);
+ }
+
+
+ #pragma mark - testgetRegionCodeForCountryCode
+ {
+ STAssertEqualObjects(@"US", [phoneUtil getRegionCodeForCountryCode:@1], nil);
+ STAssertEqualObjects(@"GB", [phoneUtil getRegionCodeForCountryCode:@44], nil);
+ STAssertEqualObjects(@"DE", [phoneUtil getRegionCodeForCountryCode:@49], nil);
+ STAssertEqualObjects(@"001", [phoneUtil getRegionCodeForCountryCode:@800], nil);
+ STAssertEqualObjects(@"001", [phoneUtil getRegionCodeForCountryCode:@979], nil);
+ }
+
+
+ #pragma mark - testgetRegionCodeForNumber
+ {
+ STAssertEqualObjects(@"BS", [phoneUtil getRegionCodeForNumber:BS_NUMBER], nil);
+ STAssertEqualObjects(@"US", [phoneUtil getRegionCodeForNumber:US_NUMBER], nil);
+ STAssertEqualObjects(@"GB", [phoneUtil getRegionCodeForNumber:GB_MOBILE], nil);
+ STAssertEqualObjects(@"001", [phoneUtil getRegionCodeForNumber:INTERNATIONAL_TOLL_FREE], nil);
+ STAssertEqualObjects(@"001", [phoneUtil getRegionCodeForNumber:UNIVERSAL_PREMIUM_RATE], nil);
+ }
+
+
+ #pragma mark - testGetRegionCodesForCountryCode
+ {
+ NSArray *regionCodesForNANPA = [phoneUtil getRegionCodesForCountryCode:@1];
+ STAssertTrue([regionCodesForNANPA containsObject:@"US"], nil);
+ STAssertTrue([regionCodesForNANPA containsObject:@"BS"], nil);
+ STAssertTrue([[phoneUtil getRegionCodesForCountryCode:@44] containsObject:@"GB"], nil);
+ STAssertTrue([[phoneUtil getRegionCodesForCountryCode:@49] containsObject:@"DE"], nil);
+ STAssertTrue([[phoneUtil getRegionCodesForCountryCode:@800] containsObject:@"001"], nil);
+ // Test with invalid country calling code.
+ STAssertTrue([[phoneUtil getRegionCodesForCountryCode:@-1] count] == 0, nil);
+ }
+
+
+ #pragma mark - testGetCountryCodeForRegion
+ {
+ STAssertTrue([[phoneUtil getCountryCodeForRegion:@"US"] isEqualToNumber:@1], nil);
+ STAssertTrue([[phoneUtil getCountryCodeForRegion:@"NZ"] isEqualToNumber:@64], nil);
+ STAssertTrue([[phoneUtil getCountryCodeForRegion:nil] isEqualToNumber:@0], nil);
+ STAssertTrue([[phoneUtil getCountryCodeForRegion:@"ZZ"] isEqualToNumber:@0], nil);
+ STAssertTrue([[phoneUtil getCountryCodeForRegion:@"001"] isEqualToNumber:@0], nil);
+ STAssertTrue([[phoneUtil getCountryCodeForRegion:@"CS"] isEqualToNumber:@0], nil);
+ }
+
+
+ #pragma mark - testGetNationalDiallingPrefixForRegion
+ {
+ STAssertEqualObjects(@"1", [phoneUtil getNddPrefixForRegion:@"US" stripNonDigits:NO], nil);
+
+ // Test non-main country to see it gets the national dialling prefix for the
+ // main country with that country calling code.
+ STAssertEqualObjects(@"1", [phoneUtil getNddPrefixForRegion:@"BS" stripNonDigits:NO], nil);
+ STAssertEqualObjects(@"0", [phoneUtil getNddPrefixForRegion:@"NZ" stripNonDigits:NO], nil);
+
+ // Test case with non digit in the national prefix.
+ STAssertEqualObjects(@"0~0", [phoneUtil getNddPrefixForRegion:@"AO" stripNonDigits:NO], nil);
+ STAssertEqualObjects(@"00", [phoneUtil getNddPrefixForRegion:@"AO" stripNonDigits:YES], nil);
+
+ // Test cases with invalid regions.
+ STAssertNil([phoneUtil getNddPrefixForRegion:nil stripNonDigits:NO], nil);
+ STAssertNil([phoneUtil getNddPrefixForRegion:@"ZZ" stripNonDigits:NO], nil);
+ STAssertNil([phoneUtil getNddPrefixForRegion:@"001" stripNonDigits:NO], nil);
+
+ // CS is already deprecated so the library doesn't support it.
+ STAssertNil([phoneUtil getNddPrefixForRegion:@"CS" stripNonDigits:NO], nil);
+ }
+
+
+ #pragma mark - testIsNANPACountry
+ {
+ STAssertTrue([phoneUtil isNANPACountry:@"US"], nil);
+ STAssertTrue([phoneUtil isNANPACountry:@"BS"], nil);
+ STAssertFalse([phoneUtil isNANPACountry:@"DE"], nil);
+ STAssertFalse([phoneUtil isNANPACountry:@"ZZ"], nil);
+ STAssertFalse([phoneUtil isNANPACountry:@"001"], nil);
+ STAssertFalse([phoneUtil isNANPACountry:nil], nil);
+ }
+
+
+ #pragma mark - testIsPossibleNumber
+ {
+ STAssertTrue([phoneUtil isPossibleNumber:US_NUMBER], nil);
+ STAssertTrue([phoneUtil isPossibleNumber:US_LOCAL_NUMBER], nil);
+ STAssertTrue([phoneUtil isPossibleNumber:GB_NUMBER], nil);
+ STAssertTrue([phoneUtil isPossibleNumber:INTERNATIONAL_TOLL_FREE], nil);
+
+ STAssertTrue([phoneUtil isPossibleNumberString:@"+1 650 253 0000" regionDialingFrom:@"US"], nil);
+ STAssertTrue([phoneUtil isPossibleNumberString:@"+1 650 GOO OGLE" regionDialingFrom:@"US"], nil);
+ STAssertTrue([phoneUtil isPossibleNumberString:@"(650) 253-0000" regionDialingFrom:@"US"], nil);
+ STAssertTrue([phoneUtil isPossibleNumberString:@"253-0000" regionDialingFrom:@"US"], nil);
+ STAssertTrue([phoneUtil isPossibleNumberString:@"+1 650 253 0000" regionDialingFrom:@"GB"], nil);
+ STAssertTrue([phoneUtil isPossibleNumberString:@"+44 20 7031 3000" regionDialingFrom:@"GB"], nil);
+ STAssertTrue([phoneUtil isPossibleNumberString:@"(020) 7031 3000" regionDialingFrom:@"GB"], nil);
+ STAssertTrue([phoneUtil isPossibleNumberString:@"7031 3000" regionDialingFrom:@"GB"], nil);
+ STAssertTrue([phoneUtil isPossibleNumberString:@"3331 6005" regionDialingFrom:@"NZ"], nil);
+ STAssertTrue([phoneUtil isPossibleNumberString:@"+800 1234 5678" regionDialingFrom:@"001"], nil);
+ }
+
+
+ #pragma mark - testIsPossibleNumberWithReason
+ {
+ // National numbers for country calling code +1 that are within 7 to 10 digits
+ // are possible.
+ STAssertEquals(NBEValidationResultIS_POSSIBLE, [phoneUtil isPossibleNumberWithReason:US_NUMBER], nil);
+ STAssertEquals(NBEValidationResultIS_POSSIBLE, [phoneUtil isPossibleNumberWithReason:US_LOCAL_NUMBER], nil);
+ STAssertEquals(NBEValidationResultTOO_LONG, [phoneUtil isPossibleNumberWithReason:US_LONG_NUMBER], nil);
+
+ NBPhoneNumber *number = [[NBPhoneNumber alloc] init];
+ [number setCountryCode:@0];
+ [number setNationalNumber:@2530000];
+ STAssertEquals(NBEValidationResultINVALID_COUNTRY_CODE, [phoneUtil isPossibleNumberWithReason:number], nil);
+
+ number = [[NBPhoneNumber alloc] init];
+ [number setCountryCode:@1];
+ [number setNationalNumber:@253000];
+ STAssertEquals(NBEValidationResultTOO_SHORT, [phoneUtil isPossibleNumberWithReason:number], nil);
+
+ number = [[NBPhoneNumber alloc] init];
+ [number setCountryCode:@65];
+ [number setNationalNumber:@1234567890];
+ STAssertEquals(NBEValidationResultIS_POSSIBLE, [phoneUtil isPossibleNumberWithReason:number], nil);
+ STAssertEquals(NBEValidationResultTOO_LONG, [phoneUtil isPossibleNumberWithReason:INTERNATIONAL_TOLL_FREE_TOO_LONG], nil);
+
+ // Try with number that we don't have metadata for.
+
+ NBPhoneNumber *adNumber = [[NBPhoneNumber alloc] init];
+ [adNumber setCountryCode:@376];
+ [adNumber setNationalNumber:@12345];
+ STAssertEquals(NBEValidationResultIS_POSSIBLE, [phoneUtil isPossibleNumberWithReason:adNumber], nil);
+
+ [adNumber setCountryCode:@376];
+ [adNumber setNationalNumber:@1];
+ STAssertEquals(NBEValidationResultTOO_SHORT, [phoneUtil isPossibleNumberWithReason:adNumber], nil);
+
+ [adNumber setCountryCode:@376];
+ [adNumber setNationalNumber:@12345678901234567];
+ STAssertEquals(NBEValidationResultTOO_LONG, [phoneUtil isPossibleNumberWithReason:adNumber], nil);
+ }
+
+
+ #pragma mark - testIsNotPossibleNumber
+ {
+ STAssertFalse([phoneUtil isPossibleNumber:US_LONG_NUMBER], nil);
+ STAssertFalse([phoneUtil isPossibleNumber:INTERNATIONAL_TOLL_FREE_TOO_LONG], nil);
+
+ NBPhoneNumber *number = [[NBPhoneNumber alloc] init];
+ [number setCountryCode:@1];
+ [number setNationalNumber:@253000];
+ STAssertFalse([phoneUtil isPossibleNumber:number], nil);
+
+ number = [[NBPhoneNumber alloc] init];
+ [number setCountryCode:@44];
+ [number setNationalNumber:@300];
+ STAssertFalse([phoneUtil isPossibleNumber:number], nil);
+ STAssertFalse([phoneUtil isPossibleNumberString:@"+1 650 253 00000" regionDialingFrom:@"US"], nil);
+ STAssertFalse([phoneUtil isPossibleNumberString:@"(650) 253-00000" regionDialingFrom:@"US"], nil);
+ STAssertFalse([phoneUtil isPossibleNumberString:@"I want a Pizza" regionDialingFrom:@"US"], nil);
+ STAssertFalse([phoneUtil isPossibleNumberString:@"253-000" regionDialingFrom:@"US"], nil);
+ STAssertFalse([phoneUtil isPossibleNumberString:@"1 3000" regionDialingFrom:@"GB"], nil);
+ STAssertFalse([phoneUtil isPossibleNumberString:@"+44 300" regionDialingFrom:@"GB"], nil);
+ STAssertFalse([phoneUtil isPossibleNumberString:@"+800 1234 5678 9" regionDialingFrom:@"001"], nil);
+ }
+
+
+ #pragma mark - testTruncateTooLongNumber
+ {
+ // GB number 080 1234 5678, but entered with 4 extra digits at the end.
+ NBPhoneNumber *tooLongNumber = [[NBPhoneNumber alloc] init];
+ [tooLongNumber setCountryCode:@44];
+ [tooLongNumber setNationalNumber:@80123456780123];
+
+ NBPhoneNumber *validNumber = [[NBPhoneNumber alloc] init];
+ [validNumber setCountryCode:@44];
+ [validNumber setNationalNumber:@8012345678];
+ STAssertTrue([phoneUtil truncateTooLongNumber:tooLongNumber], nil);
+ STAssertTrue([validNumber isEqual:tooLongNumber], nil);
+
+ // IT number 022 3456 7890, but entered with 3 extra digits at the end.
+ tooLongNumber = [[NBPhoneNumber alloc] init];
+ [tooLongNumber setCountryCode:@39];
+ [tooLongNumber setNationalNumber:@2234567890123];
+ [tooLongNumber setItalianLeadingZero:YES];
+
+ validNumber = [[NBPhoneNumber alloc] init];
+ [validNumber setCountryCode:@39];
+ [validNumber setNationalNumber:@2234567890];
+ [validNumber setItalianLeadingZero:YES];
+ STAssertTrue([phoneUtil truncateTooLongNumber:tooLongNumber], nil);
+ STAssertTrue([validNumber isEqual:tooLongNumber], nil);
+
+ // US number 650-253-0000, but entered with one additional digit at the end.
+ tooLongNumber = [US_LONG_NUMBER copy];
+ STAssertTrue([phoneUtil truncateTooLongNumber:tooLongNumber], nil);
+ STAssertTrue([US_NUMBER isEqual:tooLongNumber], nil);
+
+ tooLongNumber = [INTERNATIONAL_TOLL_FREE_TOO_LONG copy];
+ STAssertTrue([phoneUtil truncateTooLongNumber:tooLongNumber], nil);
+ STAssertTrue([INTERNATIONAL_TOLL_FREE isEqual:tooLongNumber], nil);
+
+ // Tests what happens when a valid number is passed in.
+
+ NBPhoneNumber *validNumberCopy = [validNumber copy];
+ STAssertTrue([phoneUtil truncateTooLongNumber:validNumber], nil);
+ // Tests the number is not modified.
+ STAssertTrue([validNumber isEqual:validNumberCopy], nil);
+
+ // Tests what happens when a number with invalid prefix is passed in.
+
+ NBPhoneNumber *numberWithInvalidPrefix = [[NBPhoneNumber alloc] init];
+ // The test metadata says US numbers cannot have prefix 240.
+ [numberWithInvalidPrefix setCountryCode:@1];
+ [numberWithInvalidPrefix setNationalNumber:@2401234567];
+
+ NBPhoneNumber *invalidNumberCopy = [numberWithInvalidPrefix copy];
+ STAssertFalse([phoneUtil truncateTooLongNumber:numberWithInvalidPrefix], nil);
+ // Tests the number is not modified.
+ STAssertTrue([numberWithInvalidPrefix isEqual:invalidNumberCopy], nil);
+
+ // Tests what happens when a too short number is passed in.
+
+ NBPhoneNumber *tooShortNumber = [[NBPhoneNumber alloc] init];
+ [tooShortNumber setCountryCode:@1];
+ [tooShortNumber setNationalNumber:@1234];
+
+ NBPhoneNumber *tooShortNumberCopy = [tooShortNumber copy];
+ STAssertFalse([phoneUtil truncateTooLongNumber:tooShortNumber], nil);
+ // Tests the number is not modified.
+ STAssertTrue([tooShortNumber isEqual:tooShortNumberCopy], nil);
+ }
+
+
+ #pragma mark - testIsViablePhoneNumber
+ {
+ NSLog(@"-------------- testIsViablePhoneNumber");
+ STAssertFalse([phoneUtil isViablePhoneNumber:@"1"], nil);
+ // Only one or two digits before strange non-possible punctuation.
+ STAssertFalse([phoneUtil isViablePhoneNumber:@"1+1+1"], nil);
+ STAssertFalse([phoneUtil isViablePhoneNumber:@"80+0"], nil);
+ // Two digits is viable.
+ STAssertTrue([phoneUtil isViablePhoneNumber:@"00"], nil);
+ STAssertTrue([phoneUtil isViablePhoneNumber:@"111"], nil);
+ // Alpha numbers.
+ STAssertTrue([phoneUtil isViablePhoneNumber:@"0800-4-pizza"], nil);
+ STAssertTrue([phoneUtil isViablePhoneNumber:@"0800-4-PIZZA"], nil);
+ // We need at least three digits before any alpha characters.
+ STAssertFalse([phoneUtil isViablePhoneNumber:@"08-PIZZA"], nil);
+ STAssertFalse([phoneUtil isViablePhoneNumber:@"8-PIZZA"], nil);
+ STAssertFalse([phoneUtil isViablePhoneNumber:@"12. March"], nil);
+ }
+
+
+ #pragma mark - testIsViablePhoneNumberNonAscii
+ {
+ NSLog(@"-------------- testIsViablePhoneNumberNonAscii");
+ // Only one or two digits before possible punctuation followed by more digits.
+ STAssertTrue([phoneUtil isViablePhoneNumber:@"1\u300034"], nil);
+ STAssertFalse([phoneUtil isViablePhoneNumber:@"1\u30003+4"], nil);
+ // Unicode variants of possible starting character and other allowed
+ // punctuation/digits.
+ STAssertTrue([phoneUtil isViablePhoneNumber:@"\uFF081\uFF09\u30003456789"], nil);
+ // Testing a leading + is okay.
+ STAssertTrue([phoneUtil isViablePhoneNumber:@"+1\uFF09\u30003456789"], nil);
+ }
+
+
+ #pragma mark - testExtractPossibleNumber
+ {
+ NSLog(@"-------------- testExtractPossibleNumber");
+ // Removes preceding funky punctuation and letters but leaves the rest
+ // untouched.
+ STAssertEqualObjects(@"0800-345-600", [phoneUtil extractPossibleNumber:@"Tel:0800-345-600"], nil);
+ STAssertEqualObjects(@"0800 FOR PIZZA", [phoneUtil extractPossibleNumber:@"Tel:0800 FOR PIZZA"], nil);
+ // Should not remove plus sign
+ STAssertEqualObjects(@"+800-345-600", [phoneUtil extractPossibleNumber:@"Tel:+800-345-600"], nil);
+ // Should recognise wide digits as possible start values.
+ STAssertEqualObjects(@"\uFF10\uFF12\uFF13", [phoneUtil extractPossibleNumber:@"\uFF10\uFF12\uFF13"], nil);
+ // Dashes are not possible start values and should be removed.
+ STAssertEqualObjects(@"\uFF11\uFF12\uFF13", [phoneUtil extractPossibleNumber:@"Num-\uFF11\uFF12\uFF13"], nil);
+ // If not possible number present, return empty string.
+ STAssertEqualObjects(@"", [phoneUtil extractPossibleNumber:@"Num-...."], nil);
+ // Leading brackets are stripped - these are not used when parsing.
+ STAssertEqualObjects(@"650) 253-0000", [phoneUtil extractPossibleNumber:@"(650) 253-0000"], nil);
+
+ // Trailing non-alpha-numeric characters should be removed.
+ STAssertEqualObjects(@"650) 253-0000", [phoneUtil extractPossibleNumber:@"(650) 253-0000..- .."], nil);
+ STAssertEqualObjects(@"650) 253-0000", [phoneUtil extractPossibleNumber:@"(650) 253-0000."], nil);
+ // This case has a trailing RTL char.
+ STAssertEqualObjects(@"650) 253-0000", [phoneUtil extractPossibleNumber:@"(650) 253-0000\u200F"], nil);
+ }
+
+
+ #pragma mark - testMaybeStripNationalPrefix
+ {
+ NSLog(@"-------------- testMaybeStripNationalPrefix");
+ NBPhoneMetaData *metadata = [[NBPhoneMetaData alloc] init];
+ [metadata setNationalPrefixForParsing:@"34"];
+
+ NBPhoneNumberDesc *generalDesc = [[NBPhoneNumberDesc alloc] init];
+ [generalDesc setNationalNumberPattern:@"\\d{4,8}"];
+ [metadata setGeneralDesc:generalDesc];
+
+ NBPhoneNumber *numberToStrip = [[NBPhoneNumber alloc] init];
+ [numberToStrip setRawInput:@"34356778"];
+
+ NSString *strippedNumber = @"356778";
+ NSString *rawInput = numberToStrip.rawInput;
+ STAssertTrue([phoneUtil maybeStripNationalPrefixAndCarrierCode:&rawInput metadata:metadata carrierCode:nil], nil);
+ STAssertEqualObjects(strippedNumber, rawInput, @"Should have had national prefix stripped.");
+
+ // Retry stripping - now the number should not start with the national prefix,
+ // so no more stripping should occur.
+ STAssertFalse([phoneUtil maybeStripNationalPrefixAndCarrierCode:&rawInput metadata:metadata carrierCode:nil], nil);
+ STAssertEqualObjects(strippedNumber, rawInput, @"Should have had no change - no national prefix present.");
+
+ // Some countries have no national prefix. Repeat test with none specified.
+ [metadata setNationalPrefixForParsing:@""];
+ STAssertFalse([phoneUtil maybeStripNationalPrefixAndCarrierCode:&rawInput metadata:metadata carrierCode:nil], nil);
+ STAssertEqualObjects(strippedNumber, rawInput, @"Should not strip anything with empty national prefix.");
+
+ // If the resultant number doesn't match the national rule, it shouldn't be
+ // stripped.
+ [metadata setNationalPrefixForParsing:@"3"];
+ numberToStrip.rawInput = @"3123";
+ rawInput = numberToStrip.rawInput;
+ strippedNumber = @"3123";
+ STAssertFalse([phoneUtil maybeStripNationalPrefixAndCarrierCode:&rawInput metadata:metadata carrierCode:nil], nil);
+ STAssertEqualObjects(strippedNumber, rawInput, @"Should have had no change - after stripping, it would not have matched the national rule.");
+
+ // Test extracting carrier selection code.
+ [metadata setNationalPrefixForParsing:@"0(81)?"];
+ numberToStrip.rawInput = @"08122123456";
+ strippedNumber = @"22123456";
+ rawInput = numberToStrip.rawInput;
+ NSString *carrierCode = @"";
+ STAssertTrue([phoneUtil maybeStripNationalPrefixAndCarrierCode:&rawInput metadata:metadata carrierCode:&carrierCode], nil);
+ STAssertEqualObjects(@"81", carrierCode, nil);
+ STAssertEqualObjects(strippedNumber, rawInput, @"Should have had national prefix and carrier code stripped.");
+
+ // If there was a transform rule, check it was applied.
+ [metadata setNationalPrefixTransformRule:@"5$15"];
+ // Note that a capturing group is present here.
+ [metadata setNationalPrefixForParsing:@"0(\\d{2})"];
+ numberToStrip.rawInput = @"031123";
+ rawInput = numberToStrip.rawInput;
+ NSString *transformedNumber = @"5315123";
+ STAssertTrue([phoneUtil maybeStripNationalPrefixAndCarrierCode:&rawInput metadata:metadata carrierCode:nil], nil);
+ STAssertEqualObjects(transformedNumber, rawInput, @"Should transform the 031 to a 5315.");
+ }
+
+
+ #pragma mark - testMaybeStripInternationalPrefix
+ {
+ NSLog(@"-------------- testMaybeStripInternationalPrefix");
+ NSString *internationalPrefix = @"00[39]";
+
+ NSString *numberToStripPrefix = @"0034567700-3898003";
+
+ // Note the dash is removed as part of the normalization.
+ NSString *strippedNumberString = @"45677003898003";
+ STAssertEquals(NBECountryCodeSourceFROM_NUMBER_WITH_IDD, [phoneUtil maybeStripInternationalPrefixAndNormalize:&numberToStripPrefix
+ possibleIddPrefix:internationalPrefix], nil);
+ STAssertEqualObjects(strippedNumberString, numberToStripPrefix, @"The number supplied was not stripped of its international prefix.");
+ // Now the number no longer starts with an IDD prefix, so it should now report
+ // FROM_DEFAULT_COUNTRY.
+ STAssertEquals(NBECountryCodeSourceFROM_DEFAULT_COUNTRY, [phoneUtil maybeStripInternationalPrefixAndNormalize:&numberToStripPrefix
+ possibleIddPrefix:internationalPrefix], nil);
+
+ numberToStripPrefix = @"00945677003898003";
+ STAssertEquals(NBECountryCodeSourceFROM_NUMBER_WITH_IDD, [phoneUtil maybeStripInternationalPrefixAndNormalize:&numberToStripPrefix
+ possibleIddPrefix:internationalPrefix], nil);
+ STAssertEqualObjects(strippedNumberString, numberToStripPrefix, @"The number supplied was not stripped of its international prefix.");
+ // Test it works when the international prefix is broken up by spaces.
+ numberToStripPrefix = @"00 9 45677003898003";
+ STAssertEquals(NBECountryCodeSourceFROM_NUMBER_WITH_IDD, [phoneUtil maybeStripInternationalPrefixAndNormalize:&numberToStripPrefix
+ possibleIddPrefix:internationalPrefix], nil);
+ STAssertEqualObjects(strippedNumberString, numberToStripPrefix, @"The number supplied was not stripped of its international prefix.");
+ // Now the number no longer starts with an IDD prefix, so it should now report
+ // FROM_DEFAULT_COUNTRY.
+ STAssertEquals(NBECountryCodeSourceFROM_DEFAULT_COUNTRY, [phoneUtil maybeStripInternationalPrefixAndNormalize:&numberToStripPrefix
+ possibleIddPrefix:internationalPrefix], nil);
+
+ // Test the + symbol is also recognised and stripped.
+ numberToStripPrefix = @"+45677003898003";
+ strippedNumberString = @"45677003898003";
+ STAssertEquals(NBECountryCodeSourceFROM_NUMBER_WITH_PLUS_SIGN, [phoneUtil maybeStripInternationalPrefixAndNormalize:&numberToStripPrefix
+ possibleIddPrefix:internationalPrefix], nil);
+ STAssertEqualObjects(strippedNumberString, numberToStripPrefix, @"The number supplied was not stripped of the plus symbol.");
+
+ // If the number afterwards is a zero, we should not strip this - no country
+ // calling code begins with 0.
+ numberToStripPrefix = @"0090112-3123";
+ strippedNumberString = @"00901123123";
+ STAssertEquals(NBECountryCodeSourceFROM_DEFAULT_COUNTRY, [phoneUtil maybeStripInternationalPrefixAndNormalize:&numberToStripPrefix
+ possibleIddPrefix:internationalPrefix], nil);
+ STAssertEqualObjects(strippedNumberString, numberToStripPrefix, @"The number supplied had a 0 after the match so should not be stripped.");
+ // Here the 0 is separated by a space from the IDD.
+ numberToStripPrefix = @"009 0-112-3123";
+ STAssertEquals(NBECountryCodeSourceFROM_DEFAULT_COUNTRY, [phoneUtil maybeStripInternationalPrefixAndNormalize:&numberToStripPrefix
+ possibleIddPrefix:internationalPrefix], nil);
+ }
+
+ #pragma mark - testMaybeExtractCountryCode
+ {
+ NSLog(@"-------------- testMaybeExtractCountryCode");
+ NBPhoneNumber *number = [[NBPhoneNumber alloc] init];
+ NBPhoneMetaData *metadata = [phoneUtil getMetadataForRegion:@"US"];
+
+ // Note that for the US, the IDD is 011.
+ NSString *phoneNumber = @"011112-3456789";
+ NSString *strippedNumber = @"123456789";
+ NSNumber *countryCallingCode = @1;
+
+ NSString *numberToFill = @"";
+
+ @try {
+ STAssertEqualObjects(countryCallingCode, [phoneUtil maybeExtractCountryCode:phoneNumber metadata:metadata
+ nationalNumber:&numberToFill keepRawInput:YES phoneNumber:&number], nil);
+ STAssertEquals(NBECountryCodeSourceFROM_NUMBER_WITH_IDD, [number.countryCodeSource intValue], nil);
+ // Should strip and normalize national significant number.
+ STAssertEqualObjects(strippedNumber, numberToFill, nil);
+ }
+ @catch (NSException *e) {
+ STFail([@"Should not have thrown an exception: " stringByAppendingString:e.reason]);
+ }
+ STAssertEquals(NBECountryCodeSourceFROM_NUMBER_WITH_IDD, [number.countryCodeSource intValue], @"Did not figure out CountryCodeSource correctly");
+ // Should strip and normalize national significant number.
+ STAssertEqualObjects(strippedNumber, numberToFill, @"Did not strip off the country calling code correctly.");
+
+ number = [[NBPhoneNumber alloc] init];
+ phoneNumber = @"+6423456789";
+ countryCallingCode = @64;
+ numberToFill = @"";
+ STAssertEqualObjects(countryCallingCode, [phoneUtil maybeExtractCountryCode:phoneNumber metadata:metadata
+ nationalNumber:&numberToFill keepRawInput:YES phoneNumber:&number], nil);
+ STAssertEquals(NBECountryCodeSourceFROM_NUMBER_WITH_PLUS_SIGN, [number.countryCodeSource intValue], @"Did not figure out CountryCodeSource correctly");
+
+ number = [[NBPhoneNumber alloc] init];
+ phoneNumber = @"+80012345678";
+ countryCallingCode = @800;
+ numberToFill = @"";
+ STAssertEqualObjects(countryCallingCode, [phoneUtil maybeExtractCountryCode:phoneNumber metadata:metadata
+ nationalNumber:&numberToFill keepRawInput:YES phoneNumber:&number], nil);
+ STAssertEquals(NBECountryCodeSourceFROM_NUMBER_WITH_PLUS_SIGN, [number.countryCodeSource intValue], @"Did not figure out CountryCodeSource correctly");
+
+ number = [[NBPhoneNumber alloc] init];
+ phoneNumber = @"2345-6789";
+ numberToFill = @"";
+ STAssertEquals(@0, [phoneUtil maybeExtractCountryCode:phoneNumber metadata:metadata
+ nationalNumber:&numberToFill keepRawInput:YES phoneNumber:&number], nil);
+ STAssertEquals(NBECountryCodeSourceFROM_DEFAULT_COUNTRY, [number.countryCodeSource intValue], @"Did not figure out CountryCodeSource correctly");
+
+
+ number = [[NBPhoneNumber alloc] init];
+ phoneNumber = @"0119991123456789";
+ numberToFill = @"";
+ @try {
+ [phoneUtil maybeExtractCountryCode:phoneNumber metadata:metadata
+ nationalNumber:&numberToFill keepRawInput:YES phoneNumber:&number];
+ STFail(@"Should have thrown an exception, no valid country calling code present.");
+ }
+ @catch (NSException *exception) {
+ // Expected.
+ STAssertEqualObjects(@"INVALID_COUNTRY_CODE", exception.name, nil);
+ }
+
+ number = [[NBPhoneNumber alloc] init];
+ phoneNumber = @"(1 610) 619 4466";
+ countryCallingCode = @1;
+ numberToFill = @"";
+ @try {
+ STAssertEqualObjects(countryCallingCode, [phoneUtil maybeExtractCountryCode:phoneNumber metadata:metadata
+ nationalNumber:&numberToFill keepRawInput:YES phoneNumber:&number],
+ @"Should have extracted the country calling code of the region passed in");
+ STAssertEquals(NBECountryCodeSourceFROM_NUMBER_WITHOUT_PLUS_SIGN, [number.countryCodeSource intValue], @"Did not figure out CountryCodeSource correctly");
+ }
+ @catch (NSException *exception) {
+ NSLog(@"%@", exception.reason);
+ }
+
+ number = [[NBPhoneNumber alloc] init];
+ phoneNumber = @"(1 610) 619 4466";
+ countryCallingCode = @1;
+ numberToFill = @"";
+ @try {
+ STAssertEqualObjects(countryCallingCode, [phoneUtil maybeExtractCountryCode:phoneNumber metadata:metadata
+ nationalNumber:&numberToFill keepRawInput:NO phoneNumber:&number], nil);
+ }
+ @catch (NSException *exception) {
+ NSLog(@"%@", exception.reason);
+ }
+
+ number = [[NBPhoneNumber alloc] init];
+ phoneNumber = @"(1 610) 619 446";
+ numberToFill = @"";
+ @try {
+ STAssertEquals(@0, [phoneUtil maybeExtractCountryCode:phoneNumber metadata:metadata
+ nationalNumber:&numberToFill keepRawInput:NO phoneNumber:&number], nil);
+ STAssertFalse(number.countryCodeSource != nil, @"Should not contain CountryCodeSource.");
+ }
+ @catch (NSException *exception) {
+ NSLog(@"%@", exception.reason);
+ }
+
+ number = [[NBPhoneNumber alloc] init];
+ phoneNumber = @"(1 610) 619";
+ numberToFill = @"";
+ @try {
+ STAssertEquals(@0, [phoneUtil maybeExtractCountryCode:phoneNumber metadata:metadata
+ nationalNumber:&numberToFill keepRawInput:YES phoneNumber:&number], nil);
+ STAssertEquals(NBECountryCodeSourceFROM_DEFAULT_COUNTRY, [number.countryCodeSource intValue], nil);
+ }
+ @catch (NSException *exception) {
+ NSLog(@"%@", exception.reason);
+ }
+ }
+
+
+ #pragma mark - testParseNationalNumber
+ {
+ NSLog(@"-------------- testParseNationalNumber");
+ // National prefix attached.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"033316005" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"33316005" defaultRegion:@"NZ"]], nil);
+
+ // National prefix attached and some formatting present.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"03-331 6005" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"03 331 6005" defaultRegion:@"NZ"]], nil);
+
+ // Test parsing RFC3966 format with a phone context.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"tel:03-331-6005;phone-context=+64" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"tel:331-6005;phone-context=+64-3" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"tel:331-6005;phone-context=+64-3" defaultRegion:@"US"]], nil);
+
+ // Test parsing RFC3966 format with optional user-defined parameters. The
+ // parameters will appear after the context if present.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"tel:03-331-6005;phone-context=+64;a=%A1" defaultRegion:@"NZ"]], nil);
+
+ // Test parsing RFC3966 with an ISDN subaddress.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"tel:03-331-6005;isub=12345;phone-context=+64" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"tel:+64-3-331-6005;isub=12345" defaultRegion:@"NZ"]], nil);
+
+ // Testing international prefixes.
+ // Should strip country calling code.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"0064 3 331 6005" defaultRegion:@"NZ"]], nil);
+
+ // Try again, but this time we have an international number with Region Code
+ // US. It should recognise the country calling code and parse accordingly.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"01164 3 331 6005" defaultRegion:@"US"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"+64 3 331 6005" defaultRegion:@"US"]], nil);
+ // We should ignore the leading plus here, since it is not followed by a valid
+ // country code but instead is followed by the IDD for the US.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"+01164 3 331 6005" defaultRegion:@"US"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"+0064 3 331 6005" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"+ 00 64 3 331 6005" defaultRegion:@"NZ"]], nil);
+
+ STAssertTrue([US_LOCAL_NUMBER isEqual:[phoneUtil parse:@"tel:253-0000;phone-context=www.google.com" defaultRegion:@"US"]], nil);
+ STAssertTrue([US_LOCAL_NUMBER isEqual:[phoneUtil parse:@"tel:253-0000;isub=12345;phone-context=www.google.com" defaultRegion:@"US"]], nil);
+ // This is invalid because no "+" sign is present as part of phone-context.
+ // The phone context is simply ignored in this case just as if it contains a
+ // domain.
+ STAssertTrue([US_LOCAL_NUMBER isEqual:[phoneUtil parse:@"tel:2530000;isub=12345;phone-context=1-650" defaultRegion:@"US"]], nil);
+ STAssertTrue([US_LOCAL_NUMBER isEqual:[phoneUtil parse:@"tel:2530000;isub=12345;phone-context=1234.com" defaultRegion:@"US"]], nil);
+
+ NBPhoneNumber *nzNumber = [[NBPhoneNumber alloc] init];
+ [nzNumber setCountryCode:@64];
+ [nzNumber setNationalNumber:@64123456];
+ STAssertTrue([nzNumber isEqual:[phoneUtil parse:@"64(0)64123456" defaultRegion:@"NZ"]], nil);
+ // Check that using a '/' is fine in a phone number.
+ STAssertTrue([DE_NUMBER isEqual:[phoneUtil parse:@"301/23456" defaultRegion:@"DE"]], nil);
+
+ NBPhoneNumber *usNumber = [[NBPhoneNumber alloc] init];
+ // Check it doesn't use the '1' as a country calling code when parsing if the
+ // phone number was already possible.
+ [usNumber setCountryCode:@1];
+ [usNumber setNationalNumber:@1234567890];
+ STAssertTrue([usNumber isEqual:[phoneUtil parse:@"123-456-7890" defaultRegion:@"US"]], nil);
+
+ // Test star numbers. Although this is not strictly valid, we would like to
+ // make sure we can parse the output we produce when formatting the number.
+ STAssertTrue([JP_STAR_NUMBER isEqual:[phoneUtil parse:@"+81 *2345" defaultRegion:@"JP"]], nil);
+
+ NBPhoneNumber *shortNumber = [[NBPhoneNumber alloc] init];
+ [shortNumber setCountryCode:@64];
+ [shortNumber setNationalNumber:@12];
+ STAssertTrue([shortNumber isEqual:[phoneUtil parse:@"12" defaultRegion:@"NZ"]], nil);
+ }
+
+
+ #pragma mark - testParseNumberWithAlphaCharacters
+ {
+ NSLog(@"-------------- testParseNumberWithAlphaCharacters");
+ // Test case with alpha characters.
+ NBPhoneNumber *tollfreeNumber = [[NBPhoneNumber alloc] init];
+ [tollfreeNumber setCountryCode:@64];
+ [tollfreeNumber setNationalNumber:@800332005];
+ STAssertTrue([tollfreeNumber isEqual:[phoneUtil parse:@"0800 DDA 005" defaultRegion:@"NZ"]], nil);
+
+ NBPhoneNumber *premiumNumber = [[NBPhoneNumber alloc] init];
+ [premiumNumber setCountryCode:@64];
+ [premiumNumber setNationalNumber:@9003326005];
+ STAssertTrue([premiumNumber isEqual:[phoneUtil parse:@"0900 DDA 6005" defaultRegion:@"NZ"]], nil);
+ // Not enough alpha characters for them to be considered intentional, so they
+ // are stripped.
+ STAssertTrue([premiumNumber isEqual:[phoneUtil parse:@"0900 332 6005a" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([premiumNumber isEqual:[phoneUtil parse:@"0900 332 600a5" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([premiumNumber isEqual:[phoneUtil parse:@"0900 332 600A5" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([premiumNumber isEqual:[phoneUtil parse:@"0900 a332 600A5" defaultRegion:@"NZ"]], nil);
+ }
+
+
+ #pragma mark - testParseMaliciousInput
+ {
+ NSLog(@"-------------- testParseMaliciousInput");
+ // Lots of leading + signs before the possible number.
+
+ NSString *maliciousNumber = @"";
+ for (int i=0; i<6000; i++)
+ {
+ maliciousNumber = [maliciousNumber stringByAppendingString:@"+"];
+ }
+
+ maliciousNumber = [maliciousNumber stringByAppendingString:@"12222-33-244 extensioB 343+"];
+ @try {
+ [phoneUtil parse:maliciousNumber defaultRegion:@"US"];
+ STFail([@"This should not parse without throwing an exception " stringByAppendingString:maliciousNumber]);
+ }
+ @catch (NSException *e) {
+ STAssertEqualObjects(@"TOO_LONG", e.name, @"Wrong error type stored in exception.");
+ }
+
+ NSString *maliciousNumberWithAlmostExt = @"";
+ for (int i=0; i<350; i++)
+ {
+ maliciousNumberWithAlmostExt = [maliciousNumberWithAlmostExt stringByAppendingString:@"200"];
+ }
+
+ [maliciousNumberWithAlmostExt stringByAppendingString:@" extensiOB 345"];
+
+ @try {
+ [phoneUtil parse:maliciousNumberWithAlmostExt defaultRegion:@"US"];
+ STFail([@"This should not parse without throwing an exception " stringByAppendingString:maliciousNumberWithAlmostExt]);
+ }
+ @catch (NSException *e) {
+ STAssertEqualObjects(@"TOO_LONG", e.name, @"Wrong error type stored in exception.");
+ }
+ }
+
+
+ #pragma mark - testParseWithInternationalPrefixes
+ {
+ NSLog(@"-------------- testParseWithInternationalPrefixes");
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"+1 (650) 253-0000" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([INTERNATIONAL_TOLL_FREE isEqual:[phoneUtil parse:@"011 800 1234 5678" defaultRegion:@"US"]], nil);
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"1-650-253-0000" defaultRegion:@"US"]], nil);
+ // Calling the US number from Singapore by using different service providers
+ // 1st test: calling using SingTel IDD service (IDD is 001)
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"0011-650-253-0000" defaultRegion:@"SG"]], nil);
+ // 2nd test: calling using StarHub IDD service (IDD is 008)
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"0081-650-253-0000" defaultRegion:@"SG"]], nil);
+ // 3rd test: calling using SingTel V019 service (IDD is 019)
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"0191-650-253-0000" defaultRegion:@"SG"]], nil);
+ // Calling the US number from Poland
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"0~01-650-253-0000" defaultRegion:@"PL"]], nil);
+ // Using '++' at the start.
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"++1 (650) 253-0000" defaultRegion:@"PL"]], nil);
+ }
+
+
+ #pragma mark - testParseNonAscii
+ {
+ NSLog(@"-------------- testParseNonAscii");
+ // Using a full-width plus sign.
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"\uFF0B1 (650) 253-0000" defaultRegion:@"SG"]], nil);
+ // Using a soft hyphen U+00AD.
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"1 (650) 253\u00AD-0000" defaultRegion:@"US"]], nil);
+ // The whole number, including punctuation, is here represented in full-width
+ // form.
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"\uFF0B\uFF11\u3000\uFF08\uFF16\uFF15\uFF10\uFF09\u3000\uFF12\uFF15\uFF13\uFF0D\uFF10\uFF10\uFF10\uFF10" defaultRegion:@"SG"]], nil);
+ // Using U+30FC dash instead.
+ STAssertTrue([US_NUMBER isEqual:[phoneUtil parse:@"\uFF0B\uFF11\u3000\uFF08\uFF16\uFF15\uFF10\uFF09\u3000\uFF12\uFF15\uFF13\u30FC\uFF10\uFF10\uFF10\uFF10" defaultRegion:@"SG"]], nil);
+
+ // Using a very strange decimal digit range (Mongolian digits).
+ // TODO(user): Support Mongolian digits
+ // STAssertTrue(US_NUMBER isEqual:
+ // [phoneUtil parse:@"\u1811 \u1816\u1815\u1810 " +
+ // '\u1812\u1815\u1813 \u1810\u1810\u1810\u1810" defaultRegion:@"US"], nil);
+ }
+
+
+ #pragma mark - testParseWithLeadingZero
+ {
+ NSLog(@"-------------- testParseWithLeadingZero");
+ STAssertTrue([IT_NUMBER isEqual:[phoneUtil parse:@"+39 02-36618 300" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([IT_NUMBER isEqual:[phoneUtil parse:@"02-36618 300" defaultRegion:@"IT"]], nil);
+ STAssertTrue([IT_MOBILE isEqual:[phoneUtil parse:@"345 678 901" defaultRegion:@"IT"]], nil);
+ }
+
+
+ #pragma mark - testParseNationalNumberArgentina
+ {
+ NSLog(@"-------------- testParseNationalNumberArgentina");
+ // Test parsing mobile numbers of Argentina.
+ NBPhoneNumber *arNumber = [[NBPhoneNumber alloc] init];
+ [arNumber setCountryCode:@54];
+ [arNumber setNationalNumber:@93435551212];
+ STAssertTrue([arNumber isEqual:[phoneUtil parse:@"+54 9 343 555 1212" defaultRegion:@"AR"]], nil);
+ STAssertTrue([arNumber isEqual:[phoneUtil parse:@"0343 15 555 1212" defaultRegion:@"AR"]], nil);
+
+ arNumber = [[NBPhoneNumber alloc] init];
+ [arNumber setCountryCode:@54];
+ [arNumber setNationalNumber:@93715654320];
+ STAssertTrue([arNumber isEqual:[phoneUtil parse:@"+54 9 3715 65 4320" defaultRegion:@"AR"]], nil);
+ STAssertTrue([arNumber isEqual:[phoneUtil parse:@"03715 15 65 4320" defaultRegion:@"AR"]], nil);
+ STAssertTrue([AR_MOBILE isEqual:[phoneUtil parse:@"911 876 54321" defaultRegion:@"AR"]], nil);
+
+ // Test parsing fixed-line numbers of Argentina.
+ STAssertTrue([AR_NUMBER isEqual:[phoneUtil parse:@"+54 11 8765 4321" defaultRegion:@"AR"]], nil);
+ STAssertTrue([AR_NUMBER isEqual:[phoneUtil parse:@"011 8765 4321" defaultRegion:@"AR"]], nil);
+
+ arNumber = [[NBPhoneNumber alloc] init];
+ [arNumber setCountryCode:@54];
+ [arNumber setNationalNumber:@3715654321];
+ STAssertTrue([arNumber isEqual:[phoneUtil parse:@"+54 3715 65 4321" defaultRegion:@"AR"]], nil);
+ STAssertTrue([arNumber isEqual:[phoneUtil parse:@"03715 65 4321" defaultRegion:@"AR"]], nil);
+
+ arNumber = [[NBPhoneNumber alloc] init];
+ [arNumber setCountryCode:@54];
+ [arNumber setNationalNumber:@2312340000];
+ STAssertTrue([arNumber isEqual:[phoneUtil parse:@"+54 23 1234 0000" defaultRegion:@"AR"]], nil);
+ STAssertTrue([arNumber isEqual:[phoneUtil parse:@"023 1234 0000" defaultRegion:@"AR"]], nil);
+ }
+
+
+ #pragma mark - testParseWithXInNumber
+ {
+ NSLog(@"-------------- testParseWithXInNumber");
+ // Test that having an 'x' in the phone number at the start is ok and that it
+ // just gets removed.
+ STAssertTrue([AR_NUMBER isEqual:[phoneUtil parse:@"01187654321" defaultRegion:@"AR"]], nil);
+ STAssertTrue([AR_NUMBER isEqual:[phoneUtil parse:@"(0) 1187654321" defaultRegion:@"AR"]], nil);
+ STAssertTrue([AR_NUMBER isEqual:[phoneUtil parse:@"0 1187654321" defaultRegion:@"AR"]], nil);
+ STAssertTrue([AR_NUMBER isEqual:[phoneUtil parse:@"(0xx) 1187654321" defaultRegion:@"AR"]], nil);
+
+ id arFromUs = [[NBPhoneNumber alloc] init];
+ [arFromUs setCountryCode:@54];
+ [arFromUs setNationalNumber:@81429712];
+ // This test is intentionally constructed such that the number of digit after
+ // xx is larger than 7, so that the number won't be mistakenly treated as an
+ // extension, as we allow extensions up to 7 digits. This assumption is okay
+ // for now as all the countries where a carrier selection code is written in
+ // the form of xx have a national significant number of length larger than 7.
+ STAssertTrue([arFromUs isEqual:[phoneUtil parse:@"011xx5481429712" defaultRegion:@"US"]], nil);
+ }
+
+
+ #pragma mark - testParseNumbersMexico
+ {
+ NSLog(@"-------------- testParseNumbersMexico");
+ // Test parsing fixed-line numbers of Mexico.
+
+ id mxNumber = [[NBPhoneNumber alloc] init];
+ [mxNumber setCountryCode:@52];
+ [mxNumber setNationalNumber:@4499780001];
+ STAssertTrue([mxNumber isEqual:[phoneUtil parse:@"+52 (449)978-0001" defaultRegion:@"MX"]], nil);
+ STAssertTrue([mxNumber isEqual:[phoneUtil parse:@"01 (449)978-0001" defaultRegion:@"MX"]], nil);
+ STAssertTrue([mxNumber isEqual:[phoneUtil parse:@"(449)978-0001" defaultRegion:@"MX"]], nil);
+
+ // Test parsing mobile numbers of Mexico.
+ mxNumber = [[NBPhoneNumber alloc] init];
+ [mxNumber setCountryCode:@52];
+ [mxNumber setNationalNumber:@13312345678];
+ STAssertTrue([mxNumber isEqual:[phoneUtil parse:@"+52 1 33 1234-5678" defaultRegion:@"MX"]], nil);
+ STAssertTrue([mxNumber isEqual:[phoneUtil parse:@"044 (33) 1234-5678" defaultRegion:@"MX"]], nil);
+ STAssertTrue([mxNumber isEqual:[phoneUtil parse:@"045 33 1234-5678" defaultRegion:@"MX"]], nil);
+ }
+
+
+ #pragma mark - testFailedParseOnInvalidNumbers
+ {
+ NSLog(@"-------------- testFailedParseOnInvalidNumbers");
+ @try {
+ NSString *sentencePhoneNumber = @"This is not a phone number";
+ [phoneUtil parse:sentencePhoneNumber defaultRegion:@"NZ"];
+ STFail([@"This should not parse without throwing an exception " stringByAppendingString:sentencePhoneNumber]);
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"NOT_A_NUMBER", e.name ,@"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *sentencePhoneNumber = @"1 Still not a number";
+ [phoneUtil parse:sentencePhoneNumber defaultRegion:@"NZ"];
+ STFail([@"This should not parse without throwing an exception " stringByAppendingString:sentencePhoneNumber]);
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"NOT_A_NUMBER", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *sentencePhoneNumber = @"1 MICROSOFT";
+ [phoneUtil parse:sentencePhoneNumber defaultRegion:@"NZ"];
+ STFail([@"This should not parse without throwing an exception " stringByAppendingString:sentencePhoneNumber]);
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"NOT_A_NUMBER", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *sentencePhoneNumber = @"12 MICROSOFT";
+ [phoneUtil parse:sentencePhoneNumber defaultRegion:@"NZ"];
+ STFail([@"This should not parse without throwing an exception " stringByAppendingString:sentencePhoneNumber]);
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"NOT_A_NUMBER", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *tooLongPhoneNumber = @"01495 72553301873 810104";
+ [phoneUtil parse:tooLongPhoneNumber defaultRegion:@"GB"];
+ STFail([@"This should not parse without throwing an exception " stringByAppendingString:tooLongPhoneNumber]);
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"TOO_LONG", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *plusMinusPhoneNumber = @"+---";
+ [phoneUtil parse:plusMinusPhoneNumber defaultRegion:@"DE"];
+ STFail([@"This should not parse without throwing an exception "stringByAppendingString:plusMinusPhoneNumber]);
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"NOT_A_NUMBER", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *plusStar = @"+***";
+ [phoneUtil parse:plusStar defaultRegion:@"DE"];
+ STFail([@"This should not parse without throwing an exception "stringByAppendingString:plusStar]);
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"NOT_A_NUMBER", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *plusStarPhoneNumber = @"+*******91";
+ [phoneUtil parse:plusStarPhoneNumber defaultRegion:@"DE"];
+ STFail([@"This should not parse without throwing an exception "stringByAppendingString:plusStarPhoneNumber]);
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"NOT_A_NUMBER", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+
+ NSString *tooShortPhoneNumber = @"+49 0";
+ [phoneUtil parse:tooShortPhoneNumber defaultRegion:@"DE"];
+ STFail([@"This should not parse without throwing an exception "stringByAppendingString:tooShortPhoneNumber]);
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"TOO_SHORT_NSN", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *invalidcountryCode = @"+210 3456 56789";
+ [phoneUtil parse:invalidcountryCode defaultRegion:@"NZ"];
+ STFail([@"This is not a recognised region code: should fail: " stringByAppendingString:invalidcountryCode]);
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"INVALID_COUNTRY_CODE", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *plusAndIddAndInvalidcountryCode = @"+ 00 210 3 331 6005";
+ [phoneUtil parse:plusAndIddAndInvalidcountryCode defaultRegion:@"NZ"];
+ STFail(@"This should not parse without throwing an exception.");
+ } @catch (NSException *e) {
+ // Expected this exception. 00 is a correct IDD, but 210 is not a valid
+ // country code.
+ STAssertEqualObjects(@"INVALID_COUNTRY_CODE", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *someNumber = @"123 456 7890";
+ [phoneUtil parse:someNumber defaultRegion:@"ZZ"];
+ STFail(@"Unknown region code not allowed: should fail.");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"INVALID_COUNTRY_CODE", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *someNumber = @"123 456 7890";
+ [phoneUtil parse:someNumber defaultRegion:@"CS"];
+ STFail(@"Deprecated region code not allowed: should fail.");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"INVALID_COUNTRY_CODE", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *someNumber = @"123 456 7890";
+ [phoneUtil parse:someNumber defaultRegion:nil];
+ STFail(@"nil region code not allowed: should fail.");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"INVALID_COUNTRY_CODE", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *someNumber = @"0044------";
+ [phoneUtil parse:someNumber defaultRegion:@"GB"];
+ STFail(@"No number provided, only region code: should fail");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"TOO_SHORT_AFTER_IDD", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *someNumber = @"0044";
+ [phoneUtil parse:someNumber defaultRegion:@"GB"];
+ STFail(@"No number provided, only region code: should fail");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"TOO_SHORT_AFTER_IDD", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *someNumber = @"011";
+ [phoneUtil parse:someNumber defaultRegion:@"US"];
+ STFail(@"Only IDD provided - should fail.");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"TOO_SHORT_AFTER_IDD", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *someNumber = @"0119";
+ [phoneUtil parse:someNumber defaultRegion:@"US"];
+ STFail(@"Only IDD provided and then 9 - should fail.");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"TOO_SHORT_AFTER_IDD", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *emptyNumber = @"";
+ // Invalid region.
+ [phoneUtil parse:emptyNumber defaultRegion:@"ZZ"];
+ STFail(@"Empty string - should fail.");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"NOT_A_NUMBER", e.name, @"Wrong error type stored in exception.");
+ }
+ @try {
+ // Invalid region.
+ [phoneUtil parse:nil defaultRegion:@"ZZ"];
+ STFail(@"nil string - should fail.");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"NOT_A_NUMBER", e.name, @"Wrong error type stored in exception.");
+ }
+ @try {
+ [phoneUtil parse:nil defaultRegion:@"US"];
+ STFail(@"nil string - should fail.");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"NOT_A_NUMBER", e.name, @"Wrong error type stored in exception.");
+ }
+
+ @try {
+ NSString *domainRfcPhoneContext = @"tel:555-1234;phone-context=www.google.com";
+ [phoneUtil parse:domainRfcPhoneContext defaultRegion:@"ZZ"];
+ STFail(@"Unknown region code not allowed: should fail.");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"INVALID_COUNTRY_CODE", e.name, @"Wrong error type stored in exception.");
+ }
+ @try {
+ // This is invalid because no '+' sign is present as part of phone-context.
+ // This should not succeed in being parsed.
+
+ NSString *invalidRfcPhoneContext = @"tel:555-1234;phone-context=1-331";
+ [phoneUtil parse:invalidRfcPhoneContext defaultRegion:@"ZZ"];
+ STFail(@"Unknown region code not allowed: should fail.");
+ } @catch (NSException *e) {
+ // Expected this exception.
+ STAssertEqualObjects(@"INVALID_COUNTRY_CODE", e.name, @"Wrong error type stored in exception.");
+ }
+ }
+
+
+ #pragma mark - testParseNumbersWithPlusWithNoRegion
+ {
+ NSLog(@"-------------- testParseNumbersWithPlusWithNoRegion");
+ // @"ZZ is allowed only if the number starts with a '+' - then the
+ // country calling code can be calculated.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"+64 3 331 6005" defaultRegion:@"ZZ"]], nil);
+ // Test with full-width plus.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"\uFF0B64 3 331 6005" defaultRegion:@"ZZ"]], nil);
+ // Test with normal plus but leading characters that need to be stripped.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"Tel: +64 3 331 6005" defaultRegion:@"ZZ"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"+64 3 331 6005" defaultRegion:nil]], nil);
+ STAssertTrue([INTERNATIONAL_TOLL_FREE isEqual:[phoneUtil parse:@"+800 1234 5678" defaultRegion:nil]], nil);
+ STAssertTrue([UNIVERSAL_PREMIUM_RATE isEqual:[phoneUtil parse:@"+979 123 456 789" defaultRegion:nil]], nil);
+
+ // Test parsing RFC3966 format with a phone context.
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"tel:03-331-6005;phone-context=+64" defaultRegion:@"ZZ"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@" tel:03-331-6005;phone-context=+64" defaultRegion:@"ZZ"]], nil);
+ STAssertTrue([NZ_NUMBER isEqual:[phoneUtil parse:@"tel:03-331-6005;isub=12345;phone-context=+64" defaultRegion:@"ZZ"]], nil);
+
+ // It is important that we set the carrier code to an empty string, since we
+ // used ParseAndKeepRawInput and no carrier code was found.
+
+ id nzNumberWithRawInput = [NZ_NUMBER copy];
+ [nzNumberWithRawInput setRawInput:@"+64 3 331 6005"];
+ [nzNumberWithRawInput setCountryCodeSource:[NSNumber numberWithInt:NBECountryCodeSourceFROM_NUMBER_WITH_PLUS_SIGN]];
+ [nzNumberWithRawInput setPreferredDomesticCarrierCode:@""];
+ STAssertTrue([nzNumberWithRawInput isEqual:[phoneUtil parseAndKeepRawInput:@"+64 3 331 6005" defaultRegion:@"ZZ"]], nil);
+ // nil is also allowed for the region code in these cases.
+ STAssertTrue([nzNumberWithRawInput isEqual:[phoneUtil parseAndKeepRawInput:@"+64 3 331 6005" defaultRegion:nil]], nil);
+ }
+
+
+ #pragma mark - testParseExtensions
+ {
+ NSLog(@"-------------- testParseExtensions");
+ NBPhoneNumber *nzNumber = [[NBPhoneNumber alloc] init];
+ [nzNumber setCountryCode:@64];
+ [nzNumber setNationalNumber:@33316005];
+ [nzNumber setExtension:@"3456"];
+ STAssertTrue([nzNumber isEqual:[phoneUtil parse:@"03 331 6005 ext 3456" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([nzNumber isEqual:[phoneUtil parse:@"03-3316005x3456" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([nzNumber isEqual:[phoneUtil parse:@"03-3316005 int.3456" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([nzNumber isEqual:[phoneUtil parse:@"03 3316005 #3456" defaultRegion:@"NZ"]], nil);
+
+ // Test the following do not extract extensions:
+ STAssertTrue([ALPHA_NUMERIC_NUMBER isEqual:[phoneUtil parse:@"1800 six-flags" defaultRegion:@"US"]], nil);
+ STAssertTrue([ALPHA_NUMERIC_NUMBER isEqual:[phoneUtil parse:@"1800 SIX FLAGS" defaultRegion:@"US"]], nil);
+ STAssertTrue([ALPHA_NUMERIC_NUMBER isEqual:[phoneUtil parse:@"0~0 1800 7493 5247" defaultRegion:@"PL"]], nil);
+ STAssertTrue([ALPHA_NUMERIC_NUMBER isEqual:[phoneUtil parse:@"(1800) 7493.5247" defaultRegion:@"US"]], nil);
+
+ // Check that the last instance of an extension token is matched.
+
+ id extnNumber = [ALPHA_NUMERIC_NUMBER copy];
+ [extnNumber setExtension:@"1234"];
+ STAssertTrue([extnNumber isEqual:[phoneUtil parse:@"0~0 1800 7493 5247 ~1234" defaultRegion:@"PL"]], nil);
+
+ // Verifying bug-fix where the last digit of a number was previously omitted
+ // if it was a 0 when extracting the extension. Also verifying a few different
+ // cases of extensions.
+
+ id ukNumber = [[NBPhoneNumber alloc] init];
+ [ukNumber setCountryCode:@44];
+ [ukNumber setNationalNumber:@2034567890];
+ [ukNumber setExtension:@"456"];
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+44 2034567890x456" defaultRegion:@"NZ"]], nil);
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+44 2034567890x456" defaultRegion:@"GB"]], nil);
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+44 2034567890 x456" defaultRegion:@"GB"]], nil);
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+44 2034567890 X456" defaultRegion:@"GB"]], nil);
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+44 2034567890 X 456" defaultRegion:@"GB"]], nil);
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+44 2034567890 X 456" defaultRegion:@"GB"]], nil);
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+44 2034567890 x 456 " defaultRegion:@"GB"]], nil);
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+44 2034567890 X 456" defaultRegion:@"GB"]], nil);
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+44-2034567890;ext=456" defaultRegion:@"GB"]], nil);
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"tel:2034567890;ext=456;phone-context=+44" defaultRegion:@"ZZ"]], nil);
+ // Full-width extension, @"extn' only.
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+442034567890\uFF45\uFF58\uFF54\uFF4E456" defaultRegion:@"GB"]], nil);
+ // 'xtn' only.
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+442034567890\uFF58\uFF54\uFF4E456" defaultRegion:@"GB"]], nil);
+ // 'xt' only.
+ STAssertTrue([ukNumber isEqual:[phoneUtil parse:@"+442034567890\uFF58\uFF54456" defaultRegion:@"GB"]], nil);
+
+ id usWithExtension = [[NBPhoneNumber alloc] init];
+ [usWithExtension setCountryCode:@1];
+ [usWithExtension setNationalNumber:@8009013355];
+ [usWithExtension setExtension:@"7246433"];
+ STAssertTrue([usWithExtension isEqual:[phoneUtil parse:@"(800) 901-3355 x 7246433" defaultRegion:@"US"]], nil);
+ STAssertTrue([usWithExtension isEqual:[phoneUtil parse:@"(800) 901-3355 , ext 7246433" defaultRegion:@"US"]], nil);
+ STAssertTrue([usWithExtension isEqual:[phoneUtil parse:@"(800) 901-3355 ,extension 7246433" defaultRegion:@"US"]], nil);
+ STAssertTrue([usWithExtension isEqual:[phoneUtil parse:@"(800) 901-3355 ,extensi\u00F3n 7246433" defaultRegion:@"US"]], nil);
+
+ // Repeat with the small letter o with acute accent created by combining
+ // characters.
+ STAssertTrue([usWithExtension isEqual:[phoneUtil parse:@"(800) 901-3355 ,extensio\u0301n 7246433" defaultRegion:@"US"]], nil);
+ STAssertTrue([usWithExtension isEqual:[phoneUtil parse:@"(800) 901-3355 , 7246433" defaultRegion:@"US"]], nil);
+ STAssertTrue([usWithExtension isEqual:[phoneUtil parse:@"(800) 901-3355 ext: 7246433" defaultRegion:@"US"]], nil);
+
+ // Test that if a number has two extensions specified, we ignore the second.
+ id usWithTwoExtensionsNumber = [[NBPhoneNumber alloc] init];
+ [usWithTwoExtensionsNumber setCountryCode:@1];
+ [usWithTwoExtensionsNumber setNationalNumber:@2121231234];
+ [usWithTwoExtensionsNumber setExtension:@"508"];
+ STAssertTrue([usWithTwoExtensionsNumber isEqual:[phoneUtil parse:@"(212)123-1234 x508/x1234" defaultRegion:@"US"]], nil);
+ STAssertTrue([usWithTwoExtensionsNumber isEqual:[phoneUtil parse:@"(212)123-1234 x508/ x1234" defaultRegion:@"US"]], nil);
+ STAssertTrue([usWithTwoExtensionsNumber isEqual:[phoneUtil parse:@"(212)123-1234 x508\\x1234" defaultRegion:@"US"]], nil);
+
+ // Test parsing numbers in the form (645) 123-1234-910# works, where the last
+ // 3 digits before the # are an extension.
+ usWithExtension = [[NBPhoneNumber alloc] init];
+ [usWithExtension setCountryCode:@1];
+ [usWithExtension setNationalNumber:@6451231234];
+ [usWithExtension setExtension:@"910"];
+ STAssertTrue([usWithExtension isEqual:[phoneUtil parse:@"+1 (645) 123 1234-910#" defaultRegion:@"US"]], nil);
+ // Retry with the same number in a slightly different format.
+ STAssertTrue([usWithExtension isEqual:[phoneUtil parse:@"+1 (645) 123 1234 ext. 910#" defaultRegion:@"US"]], nil);
+ }
+
+
+ #pragma mark - testParseAndKeepRaw
+ {
+ NSLog(@"-------------- testParseAndKeepRaw");
+ NBPhoneNumber *alphaNumericNumber = [ALPHA_NUMERIC_NUMBER copy];
+ [alphaNumericNumber setRawInput:@"800 six-flags"];
+ [alphaNumericNumber setCountryCodeSource:[NSNumber numberWithInt:NBECountryCodeSourceFROM_DEFAULT_COUNTRY]];
+ [alphaNumericNumber setPreferredDomesticCarrierCode:@""];
+ STAssertTrue([alphaNumericNumber isEqual:[phoneUtil parseAndKeepRawInput:@"800 six-flags" defaultRegion:@"US"]], nil);
+
+ id shorterAlphaNumber = [[NBPhoneNumber alloc] init];
+ [shorterAlphaNumber setCountryCode:@1];
+ [shorterAlphaNumber setNationalNumber:@8007493524];
+ [shorterAlphaNumber setRawInput:@"1800 six-flag"];
+ [shorterAlphaNumber setCountryCodeSource:[NSNumber numberWithInt:NBECountryCodeSourceFROM_NUMBER_WITHOUT_PLUS_SIGN]];
+ [shorterAlphaNumber setPreferredDomesticCarrierCode:@""];
+ STAssertTrue([shorterAlphaNumber isEqual:[phoneUtil parseAndKeepRawInput:@"1800 six-flag" defaultRegion:@"US"]], nil);
+
+ [shorterAlphaNumber setRawInput:@"+1800 six-flag"];
+ [shorterAlphaNumber setCountryCodeSource:[NSNumber numberWithInt:NBECountryCodeSourceFROM_NUMBER_WITH_PLUS_SIGN]];
+ STAssertTrue([shorterAlphaNumber isEqual:[phoneUtil parseAndKeepRawInput:@"+1800 six-flag" defaultRegion:@"NZ"]], nil);
+
+ [alphaNumericNumber setCountryCode:@1];
+ [alphaNumericNumber setNationalNumber:@8007493524];
+ [alphaNumericNumber setRawInput:@"001800 six-flag"];
+ [alphaNumericNumber setCountryCodeSource:[NSNumber numberWithInt:NBECountryCodeSourceFROM_NUMBER_WITH_IDD]];
+ STAssertTrue([alphaNumericNumber isEqual:[phoneUtil parseAndKeepRawInput:@"001800 six-flag" defaultRegion:@"NZ"]], nil);
+
+ // Invalid region code supplied.
+ @try
+ {
+ [phoneUtil parseAndKeepRawInput:@"123 456 7890" defaultRegion:@"CS"];
+ STFail(@"Deprecated region code not allowed: should fail.");
+ } @catch (NSException *e)
+ {
+ // Expected this exception.
+ STAssertEqualObjects(@"INVALID_COUNTRY_CODE", e.name, @"Wrong error type stored in exception.");
+ }
+
+ id koreanNumber = [[NBPhoneNumber alloc] init];
+ [koreanNumber setCountryCode:@82];
+ [koreanNumber setNationalNumber:@22123456];
+ [koreanNumber setRawInput:@"08122123456"];
+ [koreanNumber setCountryCodeSource:[NSNumber numberWithInt:NBECountryCodeSourceFROM_DEFAULT_COUNTRY]];
+ [koreanNumber setPreferredDomesticCarrierCode:@"81"];
+ STAssertTrue([koreanNumber isEqual:[phoneUtil parseAndKeepRawInput:@"08122123456" defaultRegion:@"KR"]], nil);
+ }
+
+
+ #pragma mark - testCountryWithNoNumberDesc
+ {
+ NSLog(@"-------------- testCountryWithNoNumberDesc");
+ // Andorra is a country where we don't have PhoneNumberDesc info in the
+ // metadata.
+ NBPhoneNumber *adNumber = [[NBPhoneNumber alloc] init];
+ [adNumber setCountryCode:@376];
+ [adNumber setNationalNumber:@12345];
+ STAssertEqualObjects(@"+376 12345", [phoneUtil format:adNumber numberFormat:NBEPhoneNumberFormatINTERNATIONAL], nil);
+ STAssertEqualObjects(@"+37612345", [phoneUtil format:adNumber numberFormat:NBEPhoneNumberFormatE164], nil);
+ STAssertEqualObjects(@"12345", [phoneUtil format:adNumber numberFormat:NBEPhoneNumberFormatNATIONAL], nil);
+ STAssertEquals(NBEPhoneNumberTypeUNKNOWN, [phoneUtil getNumberType:adNumber], nil);
+ STAssertTrue([phoneUtil isValidNumber:adNumber], nil);
+
+ // Test dialing a US number from within Andorra.
+ STAssertEqualObjects(@"00 1 650 253 0000", [phoneUtil formatOutOfCountryCallingNumber:US_NUMBER regionCallingFrom:@"AD"], nil);
+ }
+
+
+ #pragma mark - testUnknownCountryCallingCode
+ {
+ NSLog(@"-------------- testUnknownCountryCallingCode");
+ STAssertFalse([phoneUtil isValidNumber:UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT], nil);
+ // It's not very well defined as to what the E164 representation for a number
+ // with an invalid country calling code is, but just prefixing the country
+ // code and national number is about the best we can do.
+ STAssertEqualObjects(@"+212345", [phoneUtil format:UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT numberFormat:NBEPhoneNumberFormatE164], nil);
+ }
+
+
+ #pragma mark - testIsNumberMatchMatches
+ {
+ NSLog(@"-------------- testIsNumberMatchMatches");
+ // Test simple matches where formatting is different, or leading zeroes,
+ // or country calling code has been specified.
+
+ NBPhoneNumber *num1 = [phoneUtil parse:@"+64 3 331 6005" defaultRegion:@"NZ"];
+
+ NBPhoneNumber *num2 = [phoneUtil parse:@"+64 03 331 6005" defaultRegion:@"NZ"];
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:num1 second:num2], nil);
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:@"+64 3 331 6005" second:@"+64 03 331 6005"], nil);
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:@"+800 1234 5678" second:@"+80012345678"], nil);
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:@"+64 03 331-6005" second:@"+64 03331 6005"], nil);
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:@"+643 331-6005" second:@"+64033316005"], nil);
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:@"+643 331-6005" second:@"+6433316005"], nil);
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"+6433316005"], nil);
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"tel:+64-3-331-6005;isub=123"], nil);
+ // Test alpha numbers.
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:@"+1800 siX-Flags" second:@"+1 800 7493 5247"], nil);
+ // Test numbers with extensions.
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005 extn 1234" second:@"+6433316005#1234"], nil);
+ // Test proto buffers.
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:NZ_NUMBER second:@"+6403 331 6005"], nil);
+
+ NBPhoneNumber *nzNumber = [NZ_NUMBER copy];
+ [nzNumber setExtension:@"3456"];
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:nzNumber second:@"+643 331 6005 ext 3456"], nil);
+ // Check empty extensions are ignored.
+ [nzNumber setExtension:@""];
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:nzNumber second:@"+6403 331 6005"], nil);
+ // Check variant with two proto buffers.
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:nzNumber second:NZ_NUMBER], @"Numbers did not match");
+
+ // Check raw_input, country_code_source and preferred_domestic_carrier_code
+ // are ignored.
+
+ NBPhoneNumber *brNumberOne = [[NBPhoneNumber alloc] init];
+
+ NBPhoneNumber *brNumberTwo = [[NBPhoneNumber alloc] init];
+ [brNumberOne setCountryCode:@55];
+ [brNumberOne setNationalNumber:@3121286979];
+ [brNumberOne setCountryCodeSource:[NSNumber numberWithInt:NBECountryCodeSourceFROM_NUMBER_WITH_PLUS_SIGN]];
+ [brNumberOne setPreferredDomesticCarrierCode:@"12"];
+ [brNumberOne setRawInput:@"012 3121286979"];
+ [brNumberTwo setCountryCode:@55];
+ [brNumberTwo setNationalNumber:@3121286979];
+ [brNumberTwo setCountryCodeSource:[NSNumber numberWithInt:NBECountryCodeSourceFROM_DEFAULT_COUNTRY]];
+ [brNumberTwo setPreferredDomesticCarrierCode:@"14"];
+ [brNumberTwo setRawInput:@"143121286979"];
+ STAssertEquals(NBEMatchTypeEXACT_MATCH, [phoneUtil isNumberMatch:brNumberOne second:brNumberTwo], nil);
+ }
+
+ #pragma mark - testIsNumberMatchNonMatches
+ {
+ NSLog(@"-------------- testIsNumberMatchNonMatches");
+ // Non-matches.
+ STAssertEquals(NBEMatchTypeNO_MATCH, [phoneUtil isNumberMatch:@"03 331 6005" second:@"03 331 6006"], nil);
+ STAssertEquals(NBEMatchTypeNO_MATCH, [phoneUtil isNumberMatch:@"+800 1234 5678" second:@"+1 800 1234 5678"], nil);
+ // Different country calling code, partial number match.
+ STAssertEquals(NBEMatchTypeNO_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"+16433316005"], nil);
+ // Different country calling code, same number.
+ STAssertEquals(NBEMatchTypeNO_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"+6133316005"], nil);
+ // Extension different, all else the same.
+ STAssertEquals(NBEMatchTypeNO_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005 extn 1234" second:@"0116433316005#1235"], nil);
+ STAssertEquals(NBEMatchTypeNO_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005 extn 1234" second:@"tel:+64-3-331-6005;ext=1235"], nil);
+ // NSN matches, but extension is different - not the same number.
+ STAssertEquals(NBEMatchTypeNO_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005 ext.1235" second:@"3 331 6005#1234"], nil);
+
+ // Invalid numbers that can't be parsed.
+ STAssertEquals(NBEMatchTypeNOT_A_NUMBER, [phoneUtil isNumberMatch:@"4" second:@"3 331 6043"], nil);
+ STAssertEquals(NBEMatchTypeNOT_A_NUMBER, [phoneUtil isNumberMatch:@"+43" second:@"+64 3 331 6005"], nil);
+ STAssertEquals(NBEMatchTypeNOT_A_NUMBER, [phoneUtil isNumberMatch:@"+43" second:@"64 3 331 6005"], nil);
+ STAssertEquals(NBEMatchTypeNOT_A_NUMBER, [phoneUtil isNumberMatch:@"Dog" second:@"64 3 331 6005"], nil);
+ }
+
+
+ #pragma mark - testIsNumberMatchNsnMatches
+ {
+ NSLog(@"-------------- testIsNumberMatchNsnMatches");
+ // NSN matches.
+ STAssertEquals(NBEMatchTypeNSN_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"03 331 6005"], nil);
+ STAssertEquals(NBEMatchTypeNSN_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"tel:03-331-6005;isub=1234;phone-context=abc.nz"], nil);
+ STAssertEquals(NBEMatchTypeNSN_MATCH, [phoneUtil isNumberMatch:NZ_NUMBER second:@"03 331 6005"], nil);
+ // Here the second number possibly starts with the country calling code for
+ // New Zealand, although we are unsure.
+
+ NBPhoneNumber *unchangedNzNumber = [NZ_NUMBER copy];
+ STAssertEquals(NBEMatchTypeNSN_MATCH, [phoneUtil isNumberMatch:unchangedNzNumber second:@"(64-3) 331 6005"], nil);
+ // Check the phone number proto was not edited during the method call.
+ STAssertTrue([NZ_NUMBER isEqual:unchangedNzNumber], nil);
+
+ // Here, the 1 might be a national prefix, if we compare it to the US number,
+ // so the resultant match is an NSN match.
+ STAssertEquals(NBEMatchTypeNSN_MATCH, [phoneUtil isNumberMatch:US_NUMBER second:@"1-650-253-0000"], nil);
+ STAssertEquals(NBEMatchTypeNSN_MATCH, [phoneUtil isNumberMatch:US_NUMBER second:@"6502530000"], nil);
+ STAssertEquals(NBEMatchTypeNSN_MATCH, [phoneUtil isNumberMatch:@"+1 650-253 0000" second:@"1 650 253 0000"], nil);
+ STAssertEquals(NBEMatchTypeNSN_MATCH, [phoneUtil isNumberMatch:@"1 650-253 0000" second:@"1 650 253 0000"], nil);
+ STAssertEquals(NBEMatchTypeNSN_MATCH, [phoneUtil isNumberMatch:@"1 650-253 0000" second:@"+1 650 253 0000"], nil);
+ // For this case, the match will be a short NSN match, because we cannot
+ // assume that the 1 might be a national prefix, so don't remove it when
+ // parsing.
+
+ NBPhoneNumber *randomNumber = [[NBPhoneNumber alloc] init];
+ [randomNumber setCountryCode:@41];
+ [randomNumber setNationalNumber:@6502530000];
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:randomNumber second:@"1-650-253-0000"], nil);
+ }
+
+
+ #pragma mark - testIsNumberMatchShortNsnMatches
+ {
+ NSLog(@"-------------- testIsNumberMatchShortNsnMatches");
+ // Short NSN matches with the country not specified for either one or both
+ // numbers.
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"331 6005"], nil);
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"tel:331-6005;phone-context=abc.nz"], nil);
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"tel:331-6005;isub=1234;phone-context=abc.nz"], nil);
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"tel:331-6005;isub=1234;phone-context=abc.nz;a=%A1"], nil);
+ // We did not know that the '0' was a national prefix since neither number has
+ // a country code, so this is considered a SHORT_NSN_MATCH.
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"3 331-6005" second:@"03 331 6005"], nil);
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"3 331-6005" second:@"331 6005"], nil);
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"3 331-6005" second:@"tel:331-6005;phone-context=abc.nz"], nil);
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"3 331-6005" second:@"+64 331 6005"], nil);
+ // Short NSN match with the country specified.
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"03 331-6005" second:@"331 6005"], nil);
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"1 234 345 6789" second:@"345 6789"], nil);
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"+1 (234) 345 6789" second:@"345 6789"], nil);
+ // NSN matches, country calling code omitted for one number, extension missing
+ // for one.
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:@"+64 3 331-6005" second:@"3 331 6005#1234"], nil);
+ // One has Italian leading zero, one does not.
+
+ NBPhoneNumber *italianNumberOne = [[NBPhoneNumber alloc] init];
+ [italianNumberOne setCountryCode:@39];
+ [italianNumberOne setNationalNumber:@1234];
+ [italianNumberOne setItalianLeadingZero:YES];
+
+ NBPhoneNumber *italianNumberTwo = [[NBPhoneNumber alloc] init];
+ [italianNumberTwo setCountryCode:@39];
+ [italianNumberTwo setNationalNumber:@1234];
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:italianNumberOne second:italianNumberTwo], nil);
+ // One has an extension, the other has an extension of ''.
+ [italianNumberOne setExtension:@"1234"];
+ italianNumberOne.italianLeadingZero = NO;
+ [italianNumberTwo setExtension:@""];
+ STAssertEquals(NBEMatchTypeSHORT_NSN_MATCH, [phoneUtil isNumberMatch:italianNumberOne second:italianNumberTwo], nil);
+ }
+
+
+ #pragma mark - testCanBeInternationallyDialled
+ {
+ NSLog(@"-------------- testCanBeInternationallyDialled");
+ // We have no-international-dialling rules for the US in our test metadata
+ // that say that toll-free numbers cannot be dialled internationally.
+ STAssertFalse([phoneUtil canBeInternationallyDialled:US_TOLLFREE], nil);
+
+ // Normal US numbers can be internationally dialled.
+ STAssertTrue([phoneUtil canBeInternationallyDialled:US_NUMBER], nil);
+
+ // Invalid number.
+ STAssertTrue([phoneUtil canBeInternationallyDialled:US_LOCAL_NUMBER], nil);
+
+ // We have no data for NZ - should return true.
+ STAssertTrue([phoneUtil canBeInternationallyDialled:NZ_NUMBER], nil);
+ STAssertTrue([phoneUtil canBeInternationallyDialled:INTERNATIONAL_TOLL_FREE], nil);
+ }
+
+
+ #pragma mark - testIsAlphaNumber
+ {
+ NSLog(@"-------------- testIsAlphaNumber");
+ STAssertTrue([phoneUtil isAlphaNumber:@"1800 six-flags"], nil);
+ STAssertTrue([phoneUtil isAlphaNumber:@"1800 six-flags ext. 1234"], nil);
+ STAssertTrue([phoneUtil isAlphaNumber:@"+800 six-flags"], nil);
+ STAssertTrue([phoneUtil isAlphaNumber:@"180 six-flags"], nil);
+ STAssertFalse([phoneUtil isAlphaNumber:@"1800 123-1234"], nil);
+ STAssertFalse([phoneUtil isAlphaNumber:@"1 six-flags"], nil);
+ STAssertFalse([phoneUtil isAlphaNumber:@"18 six-flags"], nil);
+ STAssertFalse([phoneUtil isAlphaNumber:@"1800 123-1234 extension: 1234"], nil);
+ STAssertFalse([phoneUtil isAlphaNumber:@"+800 1234-1234"], nil);
+ }
+}
+@end
diff --git a/libPhoneNumberTests/en.lproj/InfoPlist.strings b/libPhoneNumberTests/en.lproj/InfoPlist.strings
new file mode 100644
index 0000000..477b28f
--- /dev/null
+++ b/libPhoneNumberTests/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
diff --git a/libPhoneNumberTests/index.php b/libPhoneNumberTests/index.php
new file mode 100644
index 0000000..082b7db
--- /dev/null
+++ b/libPhoneNumberTests/index.php
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+
+<?PHP
+ $mode = isset($_REQUEST['test']) ? true:false;
+ $metadataSrc = "./libphonenumber-read-only/javascript/i18n/phonenumbers/metadata.js";
+ $fileName = "PhoneNumberMetaData";
+
+ if ($mode)
+ {
+ $metadataSrc = "./libphonenumber-read-only/javascript/i18n/phonenumbers/metadatafortesting.js";
+ $fileName = "PhoneNumberMetaDataForTesting";
+ }
+?>
+
+<head>
+ <title>libPhoneNumber for iOS metadata generator</title>
+ <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script>
+ <script>
+ goog.require('goog.proto2.Message');
+ goog.require('goog.dom');
+ goog.require('goog.json');
+ goog.require('goog.array');
+ goog.require('goog.proto2.ObjectSerializer');
+ goog.require('goog.string.StringBuffer');
+ </script>
+ <script src="./libphonenumber-read-only/javascript/i18n/phonenumbers/phonemetadata.pb.js"></script>
+ <script src="./libphonenumber-read-only/javascript/i18n/phonenumbers/phonenumber.pb.js"></script>
+ <script src=<?PHP echo '"'.$metadataSrc.'"'; ?>></script>
+ <script src="./libphonenumber-read-only/javascript/i18n/phonenumbers/phonenumberutil.js"></script>
+ <script src="./libphonenumber-read-only/javascript/i18n/phonenumbers/asyoutypeformatter.js"></script>
+ <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
+ <script>
+ goog.require('i18n.phonenumbers.metadata');
+ $(document).ready(function () {
+ var goodDomElement = goog.dom.getElement;
+ var jsonData = encodeURIComponent(JSON.stringify(i18n.phonenumbers.metadata));
+ $.ajax({
+ type: "POST",
+ url: "libPhoneNumberGenerator.php",
+ data: { jsonData: jsonData, fileName: <?php echo '"'.$fileName.'"'; ?> }
+ }).done(function(msg) {
+ $('#console').html(msg."");
+ });
+ });
+ </script>
+</head>
+
+<body>
+ <div id="console">Generate libPhoneNumber metadata for iOS</div>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/libPhoneNumberTests/libPhoneNumberGenerator.php b/libPhoneNumberTests/libPhoneNumberGenerator.php
new file mode 100644
index 0000000..1259921
--- /dev/null
+++ b/libPhoneNumberTests/libPhoneNumberGenerator.php
@@ -0,0 +1,15 @@
+<?PHP
+ $str = urldecode($_REQUEST['jsonData']);
+ $name = $_REQUEST['fileName'];
+
+ if ($str && $name)
+ {
+ $fp = fopen('./generatedJSON/'.$name.'.json', 'w');
+ fwrite($fp, $str);
+ fclose($fp);
+ echo "complete generate : ".$name;
+ exit;
+ }
+
+ echo "error";
+?>
\ No newline at end of file
diff --git a/libPhoneNumberTests/libPhoneNumberTests-Info.plist b/libPhoneNumberTests/libPhoneNumberTests-Info.plist
new file mode 100644
index 0000000..4af0e92
--- /dev/null
+++ b/libPhoneNumberTests/libPhoneNumberTests-Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.nhn.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/libPhoneNumberiOS/libPhoneNumberiOS-Prefix.pch b/libPhoneNumberiOS/libPhoneNumberiOS-Prefix.pch
new file mode 100644
index 0000000..14f6a52
--- /dev/null
+++ b/libPhoneNumberiOS/libPhoneNumberiOS-Prefix.pch
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'libPhoneNumberiOS' target in the 'libPhoneNumberiOS' project
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+#endif