From: | Oliver Kohll - Mailing Lists <oliver(dot)lists(at)gtwm(dot)co(dot)uk> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Cc: | David Johnston <polobo(at)yahoo(dot)com> |
Subject: | Re: Making substrings uppercase |
Date: | 2013-09-09 13:50:27 |
Message-ID: | ABDE8882-BCEB-4CF9-B7EA-8723D0CF44BF@gtwm.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 9 Sep 2013, at 14:41, David Johnston <polobo(at)yahoo(dot)com> wrote:
> Oliver Kohll - Mailing Lists wrote
>> select regexp_replace(sentence,'\*(.*?)\*','' || upper('\1'),'g') from
>> sentences;
>
> Yeah, you cannot embed a function-call result in the "replace with" section;
> it has to be a literal (with the group insertion meta-sequences allowed of
> course).
>
> I see two possible approaches.
>
> 1) Use pl/perl (or some variant thereof) which has facilities to do just
> this.
> 2) Use regexp_matches(,,'g') to explode the input string into its components
> parts. You can explode it so every character of the original string is in
> the output with the different columns containing the "raw" and "to modify"
> parts of each match. This would be done in a sub-query and then in the
> parent query you would "string_agg(...)" the matches back together while
> manipulating the columns needed "i.e., string_agg(c1 || upper(c3))"
>
> HTH
>
> David J.
>
I see, I'm going with Perl, thanks.
Oliver
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Curvey | 2013-09-09 14:00:36 | help getting a backtrace from 9.2 on Ubuntu 13.04? |
Previous Message | Marc Mamin | 2013-09-09 13:46:38 | Re: [GENERAL] Call for design: PostgreSQL mugs |