Re: [SQL] Funtion to clean up strings?

2009-02-18 Thread Gregory Stark
Andreas maps...@gmx.net writes: Hi Thanks, that really works :) Now a last extension. Some numbers were entered in a 110% perfect way with an excessive (0). +49 (0) 123 / 456 789 I have to suspect the source liked to express that it's either +49 or 0 if the +49 isn't applicable, but

Re: [SQL] Funtion to clean up strings?

2009-02-17 Thread Andreas
Hi Thanks, that really works :) Now a last extension. Some numbers were entered in a 110% perfect way with an excessive (0). +49 (0) 123 / 456 789 I have to suspect the source liked to express that it's either +49 or 0 if the +49 isn't applicable, but not both. Both together are

Re: [SQL] Funtion to clean up strings?

2009-02-17 Thread Raj Mathur
On Tuesday 17 Feb 2009, Andreas wrote: [snip] case when regexp_replace(p, E'[^0-9+]', '', 'g') ~ E'^(\\+|00)49' then '0'|| regexp_replace( regexp_replace( regexp_replace(p, E'[^0-9+()]', '', 'g') , '\\(0\\)||\\(||\\)', '', 'g') ,

Re: [SQL] Funtion to clean up strings?

2009-02-17 Thread Andreas
string_replace would only replace one searchstring at a time. In this case I need to replace 3 : (0) ( ) because there could be some braces not just as (0) since the innermost replace spares braces regardless where they are. Could one express the following in one expression 1)

[SQL] Funtion to clean up strings?

2009-02-12 Thread Andreas
Hi, I need a function that removes characters in strings that aren't in a given set of chars. e.g Input:12-34/ 56(8) I want just numbers so Output should in this case be: 1234568 Is there a solution? -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your

Re: [SQL] Funtion to clean up strings?

2009-02-12 Thread Dickson S. Guedes
2009/2/12 Andreas maps...@gmx.net: Hi, I need a function that removes characters in strings that aren't in a given set of chars. e.g Input:12-34/ 56(8) I want just numbers so Output should in this case be: 1234568 Is there a solution? One is: SELECT regexp_replace('12-34/

Re: [SQL] Funtion to clean up strings?

2009-02-12 Thread Andreas
Wow, that was fast THANKS :) now ... lets get more complicated. Phone numbers are entered: 0123/4567-89 national number 0049/123/4567-89 the same number +49/123/4567-89 still the same number should come out as 0123456789 to search in this column. 0049 and +49 -- 0

Re: [SQL] Funtion to clean up strings?

2009-02-12 Thread Raj Mathur
On Friday 13 Feb 2009, Andreas wrote: now ... lets get more complicated. Phone numbers are entered: 0123/4567-89 national number 0049/123/4567-89 the same number +49/123/4567-89 still the same number should come out as 0123456789 to search in this column. 0049