From: | Alban Hertroys <haramrae(at)gmail(dot)com> |
---|---|
To: | Eagna <eagna(at)protonmail(dot)com> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Regular expression for lower case to upper case. |
Date: | 2022-12-11 10:41:06 |
Message-ID: | 5C6EE9B5-477D-4206-8C36-D083CE54BED4@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> On 10 Dec 2022, at 12:00, Eagna <eagna(at)protonmail(dot)com> wrote:
>
>
> Hi, and thanks for your input.
>
>
>> 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.
>
>
> OK - I *_kind_* of see what you're saying.
>
> There's a small fiddle here (https://dbfiddle.uk/rhw1AdBY) if you'd care to give an outline of the solution that you propose.
If you put all the regexes and their replacements into a table[1], you could use an aggregate over them to combine all the replacements into the final string. It would need some aggregate like regex_replace_agg, which would probably be a custom aggregate.
[1]: If you stick to ASCII, you could just calculate them and even omit storing them in a physical table.
Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter J. Holzer | 2022-12-11 13:44:12 | Re: Regular expression to UPPER() a lower case string |
Previous Message | David G. Johnston | 2022-12-10 16:46:50 | Re: Regular expression for lower case to upper case. |