Re: Fault with initcap
От | Adrian Klaver |
---|---|
Тема | Re: Fault with initcap |
Дата | |
Msg-id | 1aad747a-4c6f-6afd-71e8-e18adbd29835@aklaver.com обсуждение исходный текст |
Ответ на | Re: Fault with initcap (Shaozhong SHI <shishaozhong@gmail.com>) |
Ответы |
Re: Fault with initcap
|
Список | pgsql-general |
On 10/12/21 16:03, Shaozhong SHI wrote: > > > > Hi, Adrian Klaver, > > In Python, there is a capwords. Do we have an equivalent in Postgres? https://docs.python.org/3/library/string.html?highlight=capwords#string.capwords string.capwords(s, sep=None) Split the argument into words using str.split(), capitalize each word using str.capitalize(), and join the capitalized words using str.join(). If the optional second argument sep is absent or None, runs of whitespace characters are replaced by a single space and leading and trailing whitespace are removed, otherwise sep is used to split and join the words. That is not going to do what you are proposing either as it still comes down to deciding where to split the 'words': import string string.capwords('notemachine') 'Notemachine' There are similar functions to split strings here: https://www.postgresql.org/docs/14/functions-string.html Though again they depend on some delimiter or regexp to make the split. There is no function that just 'knows' that 'notemachine' is two words and should become 'NoteMachine'. > Regards, David -- Adrian Klaver adrian.klaver@aklaver.com
В списке pgsql-general по дате отправления: