Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p41A3-0005bM-PE for pgsql-general@arkaria.postgresql.org; Sat, 10 Dec 2022 14:49:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p41A2-00081p-CW for pgsql-general@arkaria.postgresql.org; Sat, 10 Dec 2022 14:49:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p41A2-00081g-23 for pgsql-general@lists.postgresql.org; Sat, 10 Dec 2022 14:49:06 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p419w-0006xq-9y for pgsql-general@lists.postgresql.org; Sat, 10 Dec 2022 14:49:05 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 413317073; Sat, 10 Dec 2022 15:48:58 +0100 (CET) Date: Sat, 10 Dec 2022 15:48:58 +0100 From: "Peter J. Holzer" To: Eagna Cc: Gianni Ceccarelli , pgsql-general@lists.postgresql.org Subject: Re: Regular expression to UPPER() a lower case string Message-ID: <20221210144858.vmaglmltkytgemu6@hjp.at> Mail-Followup-To: Eagna , Gianni Ceccarelli , pgsql-general@lists.postgresql.org References: <5C_J_wdWjnwxieBfiMQgeIXLQ5RYXN4-W5jIZyCpkAqlhGO8GxRqwb1jCHfh0EO9SvHYcysvVUXM-ocEBPSb9A-_iiSwfY0DKvljrZ50iA4=@protonmail.com> <20221210104141.35498bc4@thenautilus.net> <20221210120654.736b59eb@nautilus> <20221210134740.2dbf966e@nautilus> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bec7nre2qkhi6pn2" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --bec7nre2qkhi6pn2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > > 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! :-) >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > So, I have no actual *_need_* for this, other than a desire to learn > and understand what's going on and why.=20 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 --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --bec7nre2qkhi6pn2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmOUnFQACgkQ8g5IURL+ KF05Kg//c1Bl3KNP+nUtmyhfVGRvJr3vOiGyaNfXneRVY5ApBf11pWyDIcv6BsZM KcliRLXTeWV+h5ZlnDtZVsA5Yu5QEaF8MhGQDaHSyUszjOLEjpKONRoVH4azFQpX WknRLCV3TSZ+O4lddB3omvKqYO7vFy+vBBZRXEFq1UBzHqRLIsJ3U3AA468ihqCH HJUx3izSDGFOujzH03pb+uFKHScQI/IuveSmZqOWjy3+pyyrFZ6Wg6DPqsluGZrb +gkhIreklGMNbI/I9rezh6b+HPNZPFtxReM5wVRS54NHSdP60Ei9tr7CY+5QuRWw tg7JdCc5jWIkfS50fHTN5hReVg0ttdlQRhtHnQi0RPmC7uFHwpe1XtJrkEvTPApD 0v2Wa8AzLWUOyqJi7uFTEO6R3wvkovnDxjLSAzmluyGyxCSH3jANDNnV/r9j/rrV VtH2V65veVzesVn7s7mLU8mq5ATmSd/DEH3cKf1XiisZk7w6BKfWUst0L1uXtwZc 77VQiw9iY29Wt/RzGdLHYuFvedyVxuot2MoxS64tS0cdqsGlMt2XhDS8r1A0xHBD /xeiQifaQLSBq57M4BGRmLIYl9SsNjevrglSSBiRB7U0wFRMoF2mOSfcZt0vbocH 1Q1v650xZ0PmkmrT/UoEF+8/8DRGsx1S7j9JGVIwf9518W2APmQ= =WReC -----END PGP SIGNATURE----- --bec7nre2qkhi6pn2--