• kingdonshel (1/15/2013)


    I was wondering has anyone ever written a regular expression thatreurns a boolean for wether a phone number is a valid phone number in the US or UK or wether its a mobile number or not.

    A technique to validate the number of digits in a string is trivial to do with a tally table. I am not sure if area codes are still standard (0 or 1 in middle position used to be a standard) or whether phone exchanges can tell you whether a number is for a mobile or land line. If there is a standard I am sure there is a regex posted on the net somewhere you could pickup and use, but it would be risky in case the standards changed. There are third party tools that do this but they work from a local database which you have to keep up to date to do the validation, and of course that would be $$$ out of pocket. I had a good experience using MelissaData products for address validation and they offer phone number validation tools as well.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato