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 1jYVcl-0005XD-3q for pgsql-bugs@arkaria.postgresql.org; Tue, 12 May 2020 14:11:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jYVcD-0001lW-B1 for pgsql-bugs@arkaria.postgresql.org; Tue, 12 May 2020 14:10:37 +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 1jYVcD-0001lP-4k for pgsql-bugs@lists.postgresql.org; Tue, 12 May 2020 14:10:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYVc6-0005Jv-9x for pgsql-bugs@lists.postgresql.org; Tue, 12 May 2020 14:10:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 04CEAScc018208; Tue, 12 May 2020 10:10:28 -0400 From: Tom Lane To: =?UTF-8?Q?Per=2D=C3=85ke_Ling?= cc: pgsql-bugs@lists.postgresql.org Subject: Re: Substring expression fails on single character input In-reply-to: References: Comments: In-reply-to =?UTF-8?Q?Per=2D=C3=85ke_Ling?= message dated "Tue, 12 May 2020 14:28:43 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18206.1589292628.1@sss.pgh.pa.us> Date: Tue, 12 May 2020 10:10:28 -0400 Message-ID: <18207.1589292628@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?UTF-8?Q?Per=2D=C3=85ke_Ling?= writes: > When using the expression *'(\S.*\S)' *to remove surrounding whitespace > (including \t and \n) it returns NULL on single character surrounded by > whitespace. I see no bug there. The pattern requires two non-white-space characters surrounding some arbitrary text, and your examples don't have that. If your goal is to trim leading/trailing whitespace I'd suggest that btrim is a lot easier route to the goal than coming up with a correct regex. regards, tom lane