Re: Regular expression to UPPER() a lower case string - Mailing list pgsql-general

From Eagna
Subject Re: Regular expression to UPPER() a lower case string
Date
Msg-id fgSp5K7HkX69er-G42suxcBE5nMS-AWqj3TtGKyF7Tgof4dlO0Q6YWDJScuagN2G2mJXydpYmTwWPpxpdMEWmkoQ1hTUaDVEyDEsW7SPgsQ=@protonmail.com
Whole thread Raw
In response to Re: Regular expression to UPPER() a lower case string  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
Responses Re: Regular expression to UPPER() a lower case string  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
List pgsql-general
Hi, and thanks for all of the input - I think I'm beginning to grok it.

> On second thought you could probably use NFD normalization to separate
> base letters from accents, uppercase the base letters and then
> (optionally) NFC normalize everything again. Still insane ;-).

As far as I can see, I can only do what I want by using the following.

If there's a monthly prize on this list for the most insanely contrived piece of code, I think this is a strong
contender:

test.x = 'abc'

SELECT
  UPPER(REGEXP_REPLACE(x, '(.)(.)(.)', '\1')) ||
  UPPER(REGEXP_REPLACE(x, '(.)(.)(.)', '\2')) ||
  UPPER(REGEXP_REPLACE(x, '(.)(.)(.)', '\3'))
FROM test;

Result: ABC

(see https://dbfiddle.uk/LQ-6udga).

Still a bit of work to do, but I'm getting there :-)

E.


> hp




pgsql-general by date:

Previous
From: Gianni Ceccarelli
Date:
Subject: Re: Regular expression to UPPER() a lower case string
Next
From: "Peter J. Holzer"
Date:
Subject: Re: Regular expression to UPPER() a lower case string