手机号码拆分为国家代码、地区代码和本地号码?
问题说明
如何将手机号码拆分为国家代码、地区代码和本地号码?例如 919567123456 拆分后
How to split mobile number into country code, area code and local number? e.g 919567123456 after split
国家代码 = 91
区号 = 9567
本地号码 = 123456
local number = 123456
正确答案
无法用简单的算法解析电话号码,您需要使用填充了每个国家/地区规则的数据表 - 因为每个国家/地区对电话号码的划分不同.
It's not possible to parse phone numbers with a simple algorithm, you need to use data tables populated with each country's rules - because each country delimits their phone numbers differently.
国家代码相当简单,只需使用 国家呼叫代码 文章中的数据在 wikipedia 中并建立一个包含所有唯一国家代码的表格.每个国家/地区都有一个唯一的前缀,这很容易.
The country code is fairly easy, just use the data from from the Country calling codes article in wikipedia and build a table of all the unique country codes. Each country has a unique prefix, so that's easy.
但是您需要查找您想要支持的每个国家/地区的规则,并使用每个国家/地区的规则提取区号.
But then you need to look up the rules for every country you want to support and extract the area code(s) using the rules for each country.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanghfjgj
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20