Re: Returning only alphanumeric values from a query - Mailing list pgsql-sql

From Osvaldo Kussama
Subject Re: Returning only alphanumeric values from a query
Date
Msg-id AANLkTinu+Mm3xMz=C5Wd03Kj26RBu4Y_40HqDY1DmPhO@mail.gmail.com
Whole thread Raw
In response to Returning only alphanumeric values from a query  (Enrique Palacios <enriquepalaciosc@gmail.com>)
List pgsql-sql
2010/7/26 Enrique Palacios <enriquepalaciosc@gmail.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


pgsql-sql by date:

Previous
From: Enrique Palacios
Date:
Subject: Returning only alphanumeric values from a query
Next
From: "Oliveiros d'Azevedo Cristina"
Date:
Subject: Re: grouping subsets