pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gianni Ceccarelli <dakkar@thenautilus.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Regular expression to UPPER() a lower case string
Date: Sat, 10 Dec 2022 13:47:40 +0000
Message-ID: <20221210134740.2dbf966e@nautilus> (raw)
In-Reply-To: <jsvR8Hv6XXLK1obPiuUM8d8JTjEuXhn6D7S3XovQYqmR8E8BPKoekiNODbMgvEeZ3OJCvV8GX8bE6yEqGsCbjSePDTzc1Pc6HMiffpGrfKA=@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>

On 2022-12-10 Eagna <eagna@protonmail.com> wrote:
> Hi again, and thanks for sticking with this.
> > You haven't explained what you're trying to accomplish.  
> 
> Ok.
> 
> CREATE TABLE test(x TEXT); 
> 
> INSERT INTO test VALUES ('abc');
> 
> SELECT   REGEXP_REPLACE(x, '<something>', '<something_else>', 'g')
> FROM test;
> 
> Expected result: ABC

`select upper(x) from test`

You haven't explained why you need regexes at all. If you want to
convert the value of a text column to uppercase, there's a function
for that.

If you want to do something else, please describe the actual thing you
want to do. Not "how", but "what".

> David Johnston suggested something along these lines:
> 
> ==========
> > RegExp by itself cannot do this. You have to match all parts of the
> > input into different capturing groups, then use lower() combined
> > with format() to build a new string. Putting the capturing groups
> > into an array is the most useful option.  
> ===========
> 
> But it's a bit above my pay grade to do this - I've tried, but no go!
> :-( It *_appears_* to me that the string's length would have to be
> hard coded under this strategy - but if that's the only way, then so
> be it.

Maybe you need to look at `regexp_split_to_array` or
`regexp_split_to_table`?

-- 
	Dakkar - <Mobilis in mobile>
	GPG public key fingerprint = A071 E618 DD2C 5901 9574
	                             6FE2 40EA 9883 7519 3F88
	                    key id = 0x75193F88






view thread (15+ messages)  latest in thread

Message-ID: <20221210134740.2dbf966e@nautilus>
Permalink:  ../20221210134740.2dbf966e@nautilus/
Also on:    postgresql.org/message-id/20221210134740.2dbf966e@nautilus

 · 

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: dakkar@thenautilus.net
  Subject: Re: Regular expression to UPPER() a lower case string
  In-Reply-To: <20221210134740.2dbf966e@nautilus>
  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>

* 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