Re: Fault with initcap

Поиск
Список
Период
Сортировка
От Steve Midgley
Тема Re: Fault with initcap
Дата
Msg-id CAJexoSLdHQcMfdnNk5xhXDPpsANMV2oOFi+3neHv=fi7QhsW6Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Fault with initcap  (Rob Sargent <robjsargent@gmail.com>)
Список pgsql-sql


On Tue, Oct 12, 2021 at 9:54 AM Rob Sargent <robjsargent@gmail.com> wrote:


> On Oct 12, 2021, at 10:30 AM, Shaozhong SHI <shishaozhong@gmail.com> wrote:
>
> I tried initcap and found a major problem with it.
>
> Initcap of notemachine is NoteMachine.
My version 12 system gives Notemachine
>
> Initcap of Sainsbury's Bank is Sainsbury'S bank.
>
> This is not expected.
>
> Anyway to get around this problem?
>


Pg v.13 doesn't have a problem with notemachine either, but does seem to screw up Sainsbury's Bank as Sainsbury'S bank.


The only way I could think of fixing this would be to swap out the apostrophe with an alpha string not present in the string, and then swap back when you're done (see example above -- I'm not recommending using "xyzxyz" - that's just an example. And ideally you'd search for your placeholder string first to be sure it doesn't exist, or escape it).

Or just use a regexp to solve your casing problem -- maybe break up your string by whitespace into array elements, uppercase the first letter of each array and the concat the array elements back?

Steve
 

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

Предыдущее
От: Rob Sargent
Дата:
Сообщение: Re: Fault with initcap
Следующее
От: JP
Дата:
Сообщение: Re: Removing JSONB key across all elements of nested array