[tpm] Regex to validate (international) phone numbers

Rob Janes janes.rob at gmail.com
Mon Aug 6 15:17:17 PDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

011 country-code zone-code phone-number

that's the syntax.  country code is 1-3 digits.  zone-codes are like
areacodes in north america, but they aren't necessarily geographic in
nature.  they may represent cellphone or marine districts which are
nation wide.

telcordia distributes an up-to-date list which is used for switching
equipment.  probably $500/month.

each country code has it's own set of zone codes.

the caribbean and various us protectorates are countries that fall in 1+
dialing.

the further you go past 011 the more dependent you become on a
subscription service.

the attached country code list is out of date.  czechoslovakia for
example is no longer 42, it has split into 420 and 421.

- -rob

Madison Kelly wrote:
> Thanks Andy and Liam!
> 
>    Number::Phone was more than I needed, but the 'is_valid' function 
> gave me enough of a pointer to work out something I think will work. As 
> for extensions, I have a separate DB column for that.
> 
>    What I do is check for the leading '+' (as this is needed by some 
> mobile GSM phones), strip off all non-digit characters, then check the 
> length. Well, I check a little more than that, but ultimately it comes 
> down to length. Then I can "clean up" the number to something standard 
> before saving it.
> 
>    http://en.wikipedia.org/wiki/List_of_country_calling_codes
> 
>    That had enough info for me to feel comfortable that I can identify 
> *most* international numbers. As for "evenings only" or alternative 
> numbers, info like that will have to go in the comments section. The 
> number asked for is simply "preferred number" so I have *something* on 
> file.
> 
>    Thanks both!
> 
> Madi
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFGt53sGEx3U8yKO8YRAqI8AJQMEPe8i2c9TObxIBjdW1nTnESnAKCKn5tI
BlfTzUCT9OBPF/RZigKFGQ==
=kMe3
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: country.txt
Url: http://mail.pm.org/pipermail/toronto-pm/attachments/20070806/10eb2554/attachment.txt 


More information about the toronto-pm mailing list