From: | Osvaldo Kussama <osvaldo(dot)kussama(at)gmail(dot)com> |
---|---|
To: | Enrique Palacios <enriquepalaciosc(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Returning only alphanumeric values from a query |
Date: | 2010-07-26 15:44:56 |
Message-ID: | AANLkTinu+Mm3xMz=C5Wd03Kj26RBu4Y_40HqDY1DmPhO@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
2010/7/26 Enrique Palacios <enriquepalaciosc(at)gmail(dot)com>:
> HI everyone,
> Im new here, this is my first mail and i would like to know how return from
> a query only alphanumeric values and these symbols: ().,-%
> Something like:
> SELECT description FROM products WHERE productid = 5
> RESULT
> ======
> X# PRODUCT %1.0/30(UN)
> DESIRED RESULT
> ==============
> X PRODUCT %1.0 30(UN)
> I read some info, but it didnt worked out for me using regular expressions
> excuse my poor english
> thank you very much
> --
Try:
bdteste=# SELECT regexp_replace('X# PRODUCT
%1.0/30(UN)',E'[^\\w\\s().,%-]',' ','g');
regexp_replace
------------------------
X PRODUCT %1.0 30(UN)
(1 row)
http://www.postgresql.org/docs/current/interactive/functions-matching.html#FUNCTIONS-POSIX-REGEXP
Osvaldo
From | Date | Subject | |
---|---|---|---|
Next Message | Oliveiros d'Azevedo Cristina | 2010-07-27 10:37:49 | Re: grouping subsets |
Previous Message | Enrique Palacios | 2010-07-26 13:55:52 | Returning only alphanumeric values from a query |