Just wanted to share this regular expression that I am working on, in
case it may be of some use to someone in this forum. The following
pattern matches NZ land line phone numbers. Pattern based on
http://en.wikipedia.org/wiki/Telephone_numbers_in_New_Zealand#Landlines.
if (preg_match('/^(?(?=64)(?P<CountryCode>64)|0?)((?:(?P<AreaCode>3|4|
6|7|9)(?!900|911|999)(?P<PhoneNumber>[2-9][0-9]{6})))$/', $subject)) {
# Successful match
} else {
# Match attempt failed
}
Match:
6497891234
97891234
097891234
No Match:
6197891234 (Australia country code)
6499001234 (900,911, 999 not valid beginning phone number)
64097891234 (there shouldn't be a 0 before the 9 when dialing
internationally)
91891234 (phone number cannot begin with 0 or 1)
57891234 (invalid area code)
I'm open to any suggestions for improvement. Regular expression for
mobile phones next.
Thanks,
David
SexWorkers.co.nz (Not Safe For Work)
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---