Re: Regular expression to UPPER() a lower case string

From: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Cc: Eagna <eagna(at)protonmail(dot)com>, Gianni Ceccarelli <dakkar(at)thenautilus(dot)net>
Subject: Re: Regular expression to UPPER() a lower case string
Date: 2022-12-11 13:44:12
Message-ID: 20221211134412.gim5u5rzxopcojn3@hjp.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2022-12-10 15:48:58 +0100, Peter J. Holzer wrote:
> 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.

Of course I had to try that:

wds=> select
normalize(
replace(
replace(
replace(
replace(
normalize('Käse', NFD),
's', 'S'
),
'k', 'K'
),
'e', 'E'
),
'a', 'A'
),
NFC
)
;
╔═══════════╗
║ normalize ║
╟───────────╢
║ KÄSE ║
╚═══════════╝
(1 row)

Works as expected.

> Still insane ;-).

I haven't changed my mind about that.

hp

--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Zheng Li 2022-12-12 04:58:27 Re: Support logical replication of DDLs
Previous Message Alban Hertroys 2022-12-11 10:41:06 Re: Regular expression for lower case to upper case.