gpt4 book ai didi

c# - 比较 'mobile numbers' - 和/或国际格式

转载 作者:太空狗 更新时间:2023-10-29 17:50:47 27 4
gpt4 key购买 nike

我正在从移动设备接收电话号码,格式是否与国际格式不同。

场景(ZA 格式仅供示例):

数据库中的注册号码始终为国际格式:+27827177982

我收到的号码可能会有所不同,例如+27827177982 = 27827177982 = 0827177982 - 号码的国际前缀是 +27

即使我没有收到国际格式,如何将其匹配到国际格式???


请记住:

我无法仅针对 1 个区域进行转换。

有没有一种简单的方法可以比较所有地区的手机号码?

前缀范围内的字符数量引用:http://en.wikipedia.org/wiki/List_of_country_calling_codes


我的想法:

  • 比较数字的最后 9 个字符,这将排除区域前缀...但是每个区域是否只有“9 个字符不包括前缀”?

  • 遍历数据库多次比较电话号码,例如检查最后 9 个数字 - 如果没有匹配 - 检查最后 10 个数字等(但可能会导致不需要的匹配)


任何帮助将不胜感激

最佳答案

您可能想为此使用一个库。例如,谷歌的 libphonenumber带有 C# 的库 port being here .特别是,这两种方法可能值得研究(强调我的)

isNumberMatch - gets a confidence level on whether two numbers could be the same.

getExampleNumber/getExampleNumberByType - provides valid example numbers for all countries/regions, with the option of specifying which type of example phone number is needed.

关于c# - 比较 'mobile numbers' - 和/或国际格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17597206/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com