Re: Fault with initcap

From: Shaozhong SHI <shishaozhong(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Fault with initcap
Date: 2021-10-12 20:50:16
Message-ID: CA+i5JwYOMPrzNgX0eu6w+NFTObKf9NCiE3BKK2bS3nNd_=FfdA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On Tue, 12 Oct 2021 at 20:34, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> On 10/12/21 09:31, Shaozhong SHI wrote:
> > I tried initcap and found a major problem with it.
>
> What Postgres version?
>
> In version 12 and 14 I get:
>
> >
> > Initcap of notemachine is NoteMachine.
>
> select initcap('notemachine');
> initcap
> -------------
> Notemachine
>
> >
> > Initcap of Sainsbury's Bank is Sainsbury'S bank.
>
> select initcap('Sainsbury''s Bank');
> initcap
> ------------------
> Sainsbury'S Bank
>
>
> Which follows the definition here:
>
> https://www.postgresql.org/docs/14/functions-string.html
>
> initcap ( text ) → text
>
> Converts the first letter of each word to upper case and the rest to
> lower case. Words are sequences of alphanumeric characters separated by
> non-alphanumeric characters.
>
> Hi, Adrian Klaver,
>

It looks like that you replicated the error.

There must be a way to do the following.

a column contains a list of words. Only the first letter of each word
should be capitalised. INITCAP can not do that. How to create a function
just to capitalised each word (substring) in a list of words/strings. This
will be very useful and create great impact.

Regards,

David

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karsten Hilbert 2021-10-12 21:09:40 Re: Fault with initcap
Previous Message Karsten Hilbert 2021-10-12 19:56:57 Aw: Re: Re: Fault with initcap

Browse pgsql-sql by date

  From Date Subject
Next Message Karsten Hilbert 2021-10-12 21:09:40 Re: Fault with initcap
Previous Message Karsten Hilbert 2021-10-12 19:56:57 Aw: Re: Re: Fault with initcap