您将使用什么规则来验证澳大利亚电话号码? [英] What rules would you use to validate an Australian Phone Number?

查看:132
本文介绍了您将使用什么规则来验证澳大利亚电话号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该怎么做才能全面验证澳大利亚电话号码?我正在编写的应用程序需要这个.您可以假设它是从澳大利亚境内拨打的.我想使用白名单方法.

What can I do to comprehensively validate an Australian Phone Number? I need this for an application I'm writing. You can assume it is dialed from within Australia. I want to use a white-list approach.

到目前为止,这是我的规则(删除所有空格后):-

Here are my rules so far (after removing any whitespace):-

  1. 以13开头,长度为6位数字
  2. 以1300开头,长10位数字
  3. 以0开头(但不是0011,因为这是国际拨号),长度为10位数字
  4. 以+61开头,后跟9位数字
  5. 以(0_)开头,后跟8位数字(_是1-9)

有什么我想念的吗?

需要使用区号,因为当用户处于不同状态时,我们可能会从一种状态下的传真服务器发送传真.

Area codes are required as we may be sending a fax from our fax server in one state when the user is in a different state.

(我不是问如何用上述规则制作一个正则表达式,但是这些规则是否正确).

(I'm not asking how to make a regexp out of the above rules, but if those rules are correct).

另请参阅:
英国电话号码
美国电话号码

See also:
UK Phone Numbers
US Phone Numbers

推荐答案

我前一段时间做过类似的事情.不可思议的Mayhem提到的Wikipedia页面是一个很好的起点.

I did a similar thing a while ago. The Wikipedia page that unthinkableMayhem mentioned was a great starting point.

一年前,我的规则如下:

As of a year ago, my rules looked something like:

02[3-9]\d{7}  NSW/ACT
03[4-9]\d{7}  VIC/TAS
07[3-9]\d{7}  QLD
08\d{8}       SA/NT/WA

04[\d]{8}     Moblies  04x[123] = Optus,  04x[456] = Voda, 04x[0789] = Telstra

0500[\d]{6}   Find me anywhere server
0550[\d]{6}   VoIP
059[\d]{7}    Enum

13[\d]{4}     Local rate
1300[\d]{6}   Local rate

1800[\d]{6}   Free call

0198[\d]{2}   Data networks (local call anyway I think)
0198[\d]{6}

190[\d]{7}    Premium rate

这篇关于您将使用什么规则来验证澳大利亚电话号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆