Regular expressions in procs

Started by Steve Manesalmost 19 years ago3 messagesgeneral
Jump to latest
#1Steve Manes
smanes@magpie.com

I apologize if I'm having a rookie brain block, but is there a way to
massage a string inside a proc to, for instance, strip it of all
non-alpha characters using a regular expression?

#2Rodrigo De León
rdeleonp@gmail.com
In reply to: Steve Manes (#1)
Re: Regular expressions in procs

On Jun 13, 9:02 am, sma...@magpie.com (Steve Manes) wrote:

I apologize if I'm having a rookie brain block, but is there a way to
massage a string inside a proc to, for instance, strip it of all
non-alpha characters using a regular expression?

regexp_replace() could work for you, see:
http://www.postgresql.org/docs/8.2/static/functions-string.html
http://www.postgresql.org/docs/8.2/static/functions-matching.html

#3Albe Laurenz
all@adv.magwien.gv.at
In reply to: Steve Manes (#1)
Re: Regular expressions in procs

Steve Manes wrote:

I apologize if I'm having a rookie brain block, but is there a way to
massage a string inside a proc to, for instance, strip it of all
non-alpha characters using a regular expression?

SELECT regexp_replace(E'--> text\\\0120815_12 <--', '[^[:alpha:]]', '',
'g');
regexp_replace
----------------
text
(1 row)

Yours,
Laurenz Albe