Re: How to split up phone numbers?

From: Rainer Pruy <Rainer(dot)Pruy(at)Acrys(dot)COM>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to split up phone numbers?
Date: 2012-02-20 18:12:02
Message-ID: 4F428CF2.8050909@acrys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear Andreas,

this will basically require some external knowledge about the numbers logic.
The Format is not so a problem in the first place.
Numbers that start with national prefix will either start with "00" or
"+" followed by the 2 or 3 digit international prefix.
City part is of variable length (2 to 5 digits for Germany) (will
require a list of city prefix numbers for correct identification).
"main" part also is of variable length, thus separation of main and
individual part only is possible with explicit knowledge about a
specific number.
(e.g.: 12345678 could be 123456-78 or 12345-678 or 1234-5678, other
splittings are unlike but not completely impossible,
only restriction is the maximum length of internationally reachable
number length - 12 digits including internat. prefix if I remember
correctly, but could also be 14, sorry)

So, while it usually is easy to produce a valid dial string from any
such number given,
splitting such number into its logical parts requires additional
information to deliver reasonable results.

Rainer

On 20.02.2012 15:49, Andreas wrote:
> Hi,
> is there a way to split up phone numbers?
> I know that's a tricky topic and it depends on the national phone
> number format.
> I'm especially interested in a solution for Germany, Swizerland and
> Austria.
>
> I've got everything in a phone number column that makes hardly sense
> like:
> +49432156780
> 0049 4321 5678 0
> 04321/5678-0
> and so on...
> Those 3 samples are actually the same number in different notations.
>
> Aim would be to get a normalized number split up in 4 seperate columns
> nr_nation
> nr_city
> nr_main
> nr_individual
>
> so I end up with
> 49 4321 5678 0 for central
> 49 4321 5678 42 for Mr. Smith
>
> Is this doable?
>
> It would be a start to at least split off nr_nation and nr_city.
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2012-02-20 20:54:07 Re: Question on Rules
Previous Message Thom Brown 2012-02-20 17:45:31 Re: How can I get list of views that are using given column in table?