Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1maS7k-0006p6-SZ for pgsql-general@arkaria.postgresql.org; Wed, 13 Oct 2021 00:28:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1maS7j-00070Q-Gv for pgsql-general@arkaria.postgresql.org; Wed, 13 Oct 2021 00:27:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1maS7i-00070I-Ee for pgsql-general@lists.postgresql.org; Wed, 13 Oct 2021 00:27:59 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1maS7f-0000D4-8J for pgsql-general@lists.postgresql.org; Wed, 13 Oct 2021 00:27:58 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id A11D15C005E; Tue, 12 Oct 2021 20:27:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 12 Oct 2021 20:27:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=u Z7K1bteTaeROWo//p5fD8QAUkXjDETDoKMjpey56Dg=; b=CSdCkX9jlcWpD+Q25 30ISpWGGTP1dsL+YAzJyaiI7MlEYsx4yAZI6ztoFD1LkGQIo08lU37DU4qleFBtI Ha1obvZNeaubt+yxgqAIeQS/qTdgWL+xj4VOgbNuHCLk4koOjGJRw4LSNpNduJfy ZDVrhml13RorMDcItRnb3xQe5VLJzSKcOQjQI8y1QY9+NJk/rXmxadQHPKcF7u6E UKAuCQrzGd3j6PgmHorPV8RyyV+P+NaSkQIMm+IVa5D20D1+F19mMwJECNGY+e6t DSIqkKv+wkHpHIsEt11jtVsSNiQtrqvLvgY/UXAM0f0bbqrUPOJstsow9S69wgQj pRUyQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=uZ7K1bteTaeROWo//p5fD8QAUkXjDETDoKMjpey56 Dg=; b=eD6DWWczPxF9Ak+xAfpmCJB7ClWVOOvFDn8+kOotX+YJdzohFuVAnb/nT F/cnzXYuc+nOYfsV5vMRe5bE6Tj7scDFQeauY/nhDGI5xpy9wEwFVMtbdXQpExy/ FHvYp7i3eoy53H1yGXRMQJMZ8yORaAMSqo+kF4hQr8ALe/aesBOojJoCTsz1180K ntvQPlFJVzeY6RW8k705EbFXQeFTiUuNS0g6/rxhBWJBboQhMlUuvC5AR2Z11kIC hdtqy+ydXMVwCpdsdPK+02gpV6piSa0miwVpqV8Ib40wwsEI2IKT3hu2bL5n/zve FsYUaRK6NBsS1dSny6AOwRdB1OAFA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddtledgfedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeehgfeuuddtleejkefhvdefffdtuedtgefgleejvdff hfeghefhkedtleejieduhfenucffohhmrghinhepphihthhhohhnrdhorhhgpdhpohhsth hgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 Oct 2021 20:27:52 -0400 (EDT) Message-ID: <1aad747a-4c6f-6afd-71e8-e18adbd29835@aklaver.com> Date: Tue, 12 Oct 2021 17:27:51 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: Fault with initcap Content-Language: en-US To: Shaozhong SHI Cc: pgsql-general References: <10fbeda1-606a-553b-3598-eca814f40bb7@aklaver.com> <157d10c3-a683-3373-3550-06113149cc51@aklaver.com> From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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