Re: Making substrings uppercase

From: Oliver Kohll - Mailing Lists <oliver(dot)lists(at)gtwm(dot)co(dot)uk>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Making substrings uppercase
Date: 2013-09-10 10:51:15
Message-ID: 6216DAAF-2DFC-4B8E-951E-FACBF5C29A9D@gtwm.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9 Sep 2013, at 21:03, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> wrote:

> select string_agg(case when words like '*%*' then upper(btrim(words, '*')) else words end, ' ')
> from regexp_split_to_table('The *quick* *brown* fox jumped over the *lazy* dog', ' ') as words;
>
> string_agg
> ----------------------------------------------
> The QUICK BROWN fox jumped over the LAZY dog

That's quite elegant. In the end I exported and used PERL, as some of my 'words' had spaces (they were ingredients like monosodium glutamate), but you could probably do a more complex regex in regexp_split_to_table to cope with that, or use pl/perl as previously suggested.

Thanks
Oliver
www.agilebase.co.uk

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2013-09-10 12:56:18 Re: Making substrings uppercase
Previous Message Giuseppe Broccolo 2013-09-10 10:37:36 Re: plpgsql code doen't work