Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPUPP-0003Nu-Er for pgsql-bugs@arkaria.postgresql.org; Sat, 11 May 2019 15:59:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hPUPN-0003zx-DG for pgsql-bugs@arkaria.postgresql.org; Sat, 11 May 2019 15:59:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPUPN-0003zk-24 for pgsql-bugs@lists.postgresql.org; Sat, 11 May 2019 15:59:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPUPG-0004IF-H2 for pgsql-bugs@lists.postgresql.org; Sat, 11 May 2019 15:59:31 +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 x4BFxLhY032566; Sat, 11 May 2019 11:59:21 -0400 From: Tom Lane To: "Daniel Verite" cc: "Robert Schreiber" , pgsql-bugs@lists.postgresql.org Subject: Re: PostgreSQL 9.3.5 substring(text from pattern for escape) bug In-reply-to: <785708a0-a64c-42ee-9173-f596c1fc92ec@manitou-mail.org> References: <785708a0-a64c-42ee-9173-f596c1fc92ec@manitou-mail.org> Comments: In-reply-to "Daniel Verite" message dated "Sat, 11 May 2019 13:18:23 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32564.1557590361.1@sss.pgh.pa.us> Date: Sat, 11 May 2019 11:59:21 -0400 Message-ID: <32565.1557590361@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Daniel Verite" writes: > Robert Schreiber wrote: >> What appears to be happening is that the _Q? on the tail_ is being >> matched, but _the Q is also being included in the collected data.__ > You seem to expect that % must be non-greedy and let the final Q? > match 1 Q instead of 0, but there doesn't appear to be anything > in the doc that supports this interpretation. > In fact, it mentions that "%" is comparable to ".*" in POSIX > regular expressions, and the latter _is_ greedy. Right. You could get the behavior you want using a non-greedy quantifier, but you'd have to use the POSIX regexp functions, not substring(). regards, tom lane