Re: Making substrings uppercase

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Oliver Kohll - Mailing Lists <oliver(dot)lists(at)gtwm(dot)co(dot)uk>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Making substrings uppercase
Date: 2013-09-09 20:03:52
Message-ID: 20130909200352.GD6068@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oliver Kohll - Mailing Lists wrote:
> Hello,
>
> Given a string with certain words surrounded by stars, e.g.
>
> The *quick* *brown* fox jumped over the *lazy* dog
>
> can you transform the words surrounded by stars with uppercase versions, i.e.

Maybe you can turn that into a resultset, then uppercase individual
words, then join them back into a string. Something like

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
(1 fila)

This is a bit simplistic, but hopefully you get the idea.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mahlon E. Smith 2013-09-09 20:04:23 Re: Streaming replication slave crash
Previous Message Scott Marlowe 2013-09-09 20:02:17 Re: Call for design: PostgreSQL mugs