Re: Making substrings uppercase - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Making substrings uppercase
Date
Msg-id 20130909200352.GD6068@eldon.alvh.no-ip.org
Whole thread Raw
In response to Making substrings uppercase  (Oliver Kohll - Mailing Lists <oliver.lists@gtwm.co.uk>)
Responses Re: Making substrings uppercase  (Oliver Kohll - Mailing Lists <oliver.lists@gtwm.co.uk>)
List 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


pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Call for design: PostgreSQL mugs
Next
From: "Mahlon E. Smith"
Date:
Subject: Re: Streaming replication slave crash