pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Filip RembiaƂkowski <filip.rembialkowski@gmail.com>
To: Andreas <maps.on@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to split up phone numbers?
Date: Mon, 20 Feb 2012 16:17:11 +0100
Message-ID: <4F4263F7.5050508@gmail.com> (raw)
In-Reply-To: <4F425DB9.3060604@gmx.net>
References: <4F425DB9.3060604@gmx.net>

At 2012-02-20 15:50, 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?
>

yes, sure - with regular expressions and/or with bunch of IF/THEN/ELSE 
blocks in PL/PgSQL.

see regexp_split_to_array, and other regex functions in the manual:

http://www.postgresql.org/docs/current/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP




view thread (4+ messages)  latest in thread

Message-ID: <4F4263F7.5050508@gmail.com>
Permalink:  ../4F4263F7.5050508@gmail.com/
Also on:    postgresql.org/message-id/4F4263F7.5050508@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: filip.rembialkowski@gmail.com, maps.on@gmx.net
  Subject: Re: How to split up phone numbers?
  In-Reply-To: <4F4263F7.5050508@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox