Re: Fault with initcap - Mailing list pgsql-general

From Shaozhong SHI
Subject Re: Fault with initcap
Date
Msg-id CA+i5JwYOMPrzNgX0eu6w+NFTObKf9NCiE3BKK2bS3nNd_=FfdA@mail.gmail.com
Whole thread Raw
In response to Re: Fault with initcap  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: Fault with initcap
Re: Fault with initcap
List pgsql-general


On Tue, 12 Oct 2021 at 20:34, Adrian Klaver <adrian.klaver@aklaver.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 

pgsql-general by date:

Previous
From: Karsten Hilbert
Date:
Subject: Aw: Re: Re: Fault with initcap
Next
From: Karsten Hilbert
Date:
Subject: Re: Fault with initcap