pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: Eagna <eagna@protonmail.com>
Cc: Gianni Ceccarelli <dakkar@thenautilus.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Regular expression to UPPER() a lower case string
Date: Sat, 10 Dec 2022 15:48:58 +0100
Message-ID: <20221210144858.vmaglmltkytgemu6@hjp.at> (raw)
In-Reply-To: <no-TAHXqJChgnBd7ktUt7mgS_bXjtckgoWF12PUsaO-OoBcCT1m_a5PHqbkvX3pM1VX1tYE1-N2obvLDoA5S7WZvi9FU0JdIvlbAEgAmZm8=@protonmail.com>
References: <5C_J_wdWjnwxieBfiMQgeIXLQ5RYXN4-W5jIZyCpkAqlhGO8GxRqwb1jCHfh0EO9SvHYcysvVUXM-ocEBPSb9A-_iiSwfY0DKvljrZ50iA4=@protonmail.com>
	<20221210104141.35498bc4@thenautilus.net>
	<PBBDM2FhmXWAycOqgjpICsUhj9Maw4OXlQAzUXVgXHKbfM6uHOlQiKcotY_eNv9nS4XcTAWnRaeGIbUIKUHUzfr9c22pvDvt5pWir2FBRn0=@protonmail.com>
	<20221210120654.736b59eb@nautilus>
	<jsvR8Hv6XXLK1obPiuUM8d8JTjEuXhn6D7S3XovQYqmR8E8BPKoekiNODbMgvEeZ3OJCvV8GX8bE6yEqGsCbjSePDTzc1Pc6HMiffpGrfKA=@protonmail.com>
	<20221210134740.2dbf966e@nautilus>
	<no-TAHXqJChgnBd7ktUt7mgS_bXjtckgoWF12PUsaO-OoBcCT1m_a5PHqbkvX3pM1VX1tYE1-N2obvLDoA5S7WZvi9FU0JdIvlbAEgAmZm8=@protonmail.com>

On 2022-12-10 14:36:04 +0000, Eagna wrote:
> > I want to index on a REGEXP_REPLACE() - I thought using lower -> upper would be a good test.
> 
> > I could always have used another REGEXP_REPLACE() for my testing,
> > but I then became "obsessed"  with the idea of using
> > REGEXP_REPLACE() as a substitute for UPPER() - kind of an obfuscated
> > code competition with myself! :-)
> 
> ========================
> 
> So, I have no actual *_need_* for this, other than a desire to learn
> and understand what's going on and why. 

You can't do that. Well, theoretically you could replace every
individual lower case letter with it's upper case equivalent:

select regexp_replace(...regexp_replace(regexp_replace(s, 'a', 'A'), 'b', 'B')... 'z', 'Z') ...

but that would be insane even for the 26 letters of the basic Latin
alphabet, much less the myriad of accented letters (and other alphabets
like Cyrillic or Greek ...).

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 ;-).

        hp

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

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (15+ messages)  latest in thread

Message-ID: <20221210144858.vmaglmltkytgemu6@hjp.at>
Permalink:  ../20221210144858.vmaglmltkytgemu6@hjp.at/
Also on:    postgresql.org/message-id/20221210144858.vmaglmltkytgemu6@hjp.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at, eagna@protonmail.com, dakkar@thenautilus.net
  Subject: Re: Regular expression to UPPER() a lower case string
  In-Reply-To: <20221210144858.vmaglmltkytgemu6@hjp.at>
  References: <5C_J_wdWjnwxieBfiMQgeIXLQ5RYXN4-W5jIZyCpkAqlhGO8GxRqwb1jCHfh0EO9SvHYcysvVUXM-ocEBPSb9A-_iiSwfY0DKvljrZ50iA4=@protonmail.com> <20221210104141.35498bc4@thenautilus.net> <PBBDM2FhmXWAycOqgjpICsUhj9Maw4OXlQAzUXVgXHKbfM6uHOlQiKcotY_eNv9nS4XcTAWnRaeGIbUIKUHUzfr9c22pvDvt5pWir2FBRn0=@protonmail.com> <20221210120654.736b59eb@nautilus> <jsvR8Hv6XXLK1obPiuUM8d8JTjEuXhn6D7S3XovQYqmR8E8BPKoekiNODbMgvEeZ3OJCvV8GX8bE6yEqGsCbjSePDTzc1Pc6HMiffpGrfKA=@protonmail.com> <20221210134740.2dbf966e@nautilus> <no-TAHXqJChgnBd7ktUt7mgS_bXjtckgoWF12PUsaO-OoBcCT1m_a5PHqbkvX3pM1VX1tYE1-N2obvLDoA5S7WZvi9FU0JdIvlbAEgAmZm8=@protonmail.com> <20221210144858.vmaglmltkytgemu6@hjp.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox