From: | "George Pavlov" <gpavlov(at)mynewplace(dot)com> |
---|---|
To: | "Geoffrey" <esoteric(at)3times25(dot)net>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Using the REPLACE command to replace all vowels |
Date: | 2006-05-08 19:37:46 |
Message-ID: | 8C5B026B51B6854CBE88121DBF097A8611FAD2@ehost010-33.exch010.intermedia.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Is there any requirement that you have to use REPLACE? Another (possibly
better) way to do the same is by doing:
select translate(your_string,'aeiou','') from your_table;
In my experience that performs much better than regexp. I just ran it on
a table of about 100K random U.S addresses and TRANSLATE outperforms
REGEXP_REPLACE by a factor of 2. I would use TRANSLATE unless you need
some of the heavier lifting that REGEXP can provide.
> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Geoffrey
> Sent: Sunday, May 07, 2006 3:54 PM
> To: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Using the REPLACE command to replace all vowels
>
> Magnus Hagander wrote:
> >> Is there a way to make seperate replacements in 1 field in
> >> one command in SQL?
> >>
> >> I need to remove all vowels (a,e,i,o,u) in a field. How would
> >> I go about that?
> >
> > Try something like
> > SELECT regexp_replace(your_string,'[aeiou]','','g') ...
> >
> > (btw, if you want all vowels, don't forget 'y' :-P)
>
> As I recall, that should be 'and sometimes y... I don't
> recall the sql
> syntax for SOMETIMES :)
>
> --
> Until later, Geoffrey
>
> Any society that would give up a little liberty to gain a little
> security will deserve neither and lose both. - Benjamin Franklin
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
From | Date | Subject | |
---|---|---|---|
Next Message | Volkan YAZICI | 2006-05-08 19:38:02 | Re: intarray internals |
Previous Message | George Pavlov | 2006-05-08 19:26:48 | exporting quoted CSV data from a query |