Re: Regular expression to UPPER() a lower case string
От | Peter J. Holzer |
---|---|
Тема | Re: Regular expression to UPPER() a lower case string |
Дата | |
Msg-id | 20221210161606.dzd4lmxahtijqrm5@hjp.at обсуждение исходный текст |
Ответ на | Re: Regular expression to UPPER() a lower case string (Eagna <eagna@protonmail.com>) |
Список | pgsql-general |
On 2022-12-10 15:37:01 +0000, Eagna wrote: > Hi, and thanks for all of the input - I think I'm beginning to grok it. I'm not so sure about that > As far as I can see, I can only do what I want by using the following. > > If there's a monthly prize on this list for the most insanely > contrived piece of code, I think this is a strong contender: > > test.x = 'abc' > > SELECT > UPPER(REGEXP_REPLACE(x, '(.)(.)(.)', '\1')) || > UPPER(REGEXP_REPLACE(x, '(.)(.)(.)', '\2')) || > UPPER(REGEXP_REPLACE(x, '(.)(.)(.)', '\3')) > FROM test; > > Result: ABC I don't think this does what you want it to do: wds=> SELECT x, UPPER(REGEXP_REPLACE(x, '(.)(.)(.)', '\1')) || UPPER(REGEXP_REPLACE(x, '(.)(.)(.)', '\2')) || UPPER(REGEXP_REPLACE(x, '(.)(.)(.)', '\3')) FROM test; ╔═════════════╤═════════════════════════════╗ ║ x │ ?column? ║ ╟─────────────┼─────────────────────────────╢ ║ abc_def_ghi │ A_DEF_GHIB_DEF_GHIC_DEF_GHI ║ ╚═════════════╧═════════════════════════════╝ (I admit it took me at least a minute to figure out what was happening here) hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"
Вложения
В списке pgsql-general по дате отправления: