Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What rules would you use to validate an Australian Phone Number?

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. Starts with 13 and is 6 digits long
  2. Starts with 1300 and is 10 digits long
  3. Starts with 0 (but not 0011 as this is international dialing) and is 10 digits long
  4. Starts with +61 followed by 9 digits
  5. Starts with (0_) followed by 8 digits (where _ is 1-9)

Is there anything I have missed?

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

like image 585
WW. Avatar asked Nov 26 '08 23:11

WW.


1 Answers

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
like image 141
Matthewd Avatar answered Sep 23 '22 16:09

Matthewd