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

Поиск
Список
Период
Сортировка
От Eagna
Тема Re: Regular expression to UPPER() a lower case string
Дата
Msg-id jsvR8Hv6XXLK1obPiuUM8d8JTjEuXhn6D7S3XovQYqmR8E8BPKoekiNODbMgvEeZ3OJCvV8GX8bE6yEqGsCbjSePDTzc1Pc6HMiffpGrfKA=@protonmail.com
обсуждение исходный текст
Ответ на Re: Regular expression to UPPER() a lower case string  (Gianni Ceccarelli <dakkar@thenautilus.net>)
Ответы Re: Regular expression to UPPER() a lower case string  (Gianni Ceccarelli <dakkar@thenautilus.net>)
Список pgsql-general

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

See fiddle here: https://dbfiddle.uk/Q2qXXwtF

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
wouldhave to be hard coded under this strategy - but if that's the only way, then so be it. 


I'd just be interested to see a solution based on DJ's suggestion or any other code that would use REGEXP_REPLACE() to
dowhat I want - preferably without hard coding, but if it's absolutely necessary. 

Thanks for any input.

E.






В списке pgsql-general по дате отправления:

Предыдущее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: Regular expression for lower case to upper case.
Следующее
От: Gianni Ceccarelli
Дата:
Сообщение: Re: Regular expression to UPPER() a lower case string