Search Postgresql Archives

Re: Fault with initcap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux