gpt4 book ai didi

javascript - 国际号码格式列表

转载 作者:行者123 更新时间:2023-12-02 20:23:14 25 4
gpt4 key购买 nike

我想构建一个验证器(javascript)来验证来自不同国家/地区的号码,

我希望能够使用这个骨架来调用它 phone('NZ', '049234567', false, false);

分别是“国家/地区前缀”、“号码”、“固定电话”、“国际”。

我将如何去做这样的事情?

目前我正在考虑做类似的事情

var phones = {
NZ: {
national: {
landline: [
'03{2,9}n(6)', //read as 03[a number between 2 and 9][a random number][repeat previous expression 6 times]
'04{2,9}n(6)', //read as 04[a number between 2 and 9][a random number][repeat previous expression 6 times]
'06{2,9}n(6)', //read as 06[a number between 2 and 9][a random number][repeat previous expression 6 times]
'07{2,9}n(6)', //read as 07[a number between 2 and 9][a random number][repeat previous expression 6 times]
'09{2,9}n(6)' //read as 09[a number between 2 and 9][a random number][repeat previous expression 6 times]
],
mobile: [
'020n(7,10)', //read as 020[a random number][repeat previous expression between 7 and 10 times]
'021n(7,10)', //read as 021[a random number][repeat previous expression between 7 and 10 times]
'022n(7,10)', //read as 022[a random number][repeat previous expression between 7 and 10 times]
'027n(7,10)', //read as 027[a random number][repeat previous expression between 7 and 10 times]
'029n(7,10)' //read as 029[a random number][repeat previous expression between 7 and 10 times]
]
},
international: {
landline: [
'+643{2,9}n(6)', //read as +643[a number between 2 and 9][a random number][repeat previous expression 6 times]
'+644{2,9}n(6)', //read as +644[a number between 2 and 9][a random number][repeat previous expression 6 times]
'+646{2,9}n(6)', //read as +646[a number between 2 and 9][a random number][repeat previous expression 6 times]
'+647{2,9}n(6)', //read as +647[a number between 2 and 9][a random number][repeat previous expression 6 times]
'+649{2,9}n(6)' //read as +649[a number between 2 and 9][a random number][repeat previous expression 6 times]
],
mobile: [
'+6420n(7,10)', //read as +6420[a random number][repeat previous expression between 7 and 10 times]
'+6421n(7,10)', //read as +6421[a random number][repeat previous expression between 7 and 10 times]
'+6422n(7,10)', //read as +6422[a random number][repeat previous expression between 7 and 10 times]
'+6427n(7,10)', //read as +6427[a random number][repeat previous expression between 7 and 10 times]
'+6429n(7,10)' //read as +6429[a random number][repeat previous expression between 7 and 10 times]
]
}
}
}

最佳答案

关于javascript - 国际号码格式列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5240326/

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