Обсуждение: Returning only alphanumeric values from a query
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
--
Enrique Palacios
RRHH - Informática
Farmacias RedFarma Calama
RRHH - Informática
Farmacias RedFarma Calama
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