| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Kenneth Tilton <kentilton(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: string filtering in postgres? |
| Date: | 2009-04-16 20:55:11 |
| Message-ID: | 4975.1239915311@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Kenneth Tilton <kentilton(at)gmail(dot)com> writes:
> I need to normalize a column for search purposes by stripping all
> non-alphanumeric characters:
> Without much luck. Can this even be done with regex, or should I just
> write a custom sql function?
Perhaps along the lines of
regression=# select regexp_replace('ABC!$56xyz, %', '[^A-Za-z0-9]', '', 'g');
regexp_replace
----------------
ABC56xyz
(1 row)
This isn't going to be tremendously efficient for very long strings,
but I doubt you could do much better without resorting to a C function.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bill Moran | 2009-04-16 21:06:13 | Re: Looking for advice on database encryption |
| Previous Message | Thomas Kellerer | 2009-04-16 20:52:12 | Re: Looking for advice on database encryption |