Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZMdgH-0003ET-5v for pgsql-bugs@arkaria.postgresql.org; Tue, 04 Aug 2015 14:59:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZMdgG-0008AZ-N1 for pgsql-bugs@arkaria.postgresql.org; Tue, 04 Aug 2015 14:59:04 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZMdgG-0008AP-8T for pgsql-bugs@postgresql.org; Tue, 04 Aug 2015 14:59:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZMdgD-0004x1-Ce for pgsql-bugs@postgresql.org; Tue, 04 Aug 2015 14:59:03 +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 t74Ewv7Y026004; Tue, 4 Aug 2015 10:58:57 -0400 From: Tom Lane To: =?iso-8859-1?B?Q2hyaXN0aWFuIE3kY2hsZXI=?= cc: "David G. Johnston" , "pgsql-bugs@postgresql.org" Subject: Re: BUG #13538: REGEX non-greedy is working incorrectly (and also greedy matches fail if non-greedy is present) In-reply-to: References: <20150803224450.1115.8803@wrigleys.postgresql.org>, Comments: In-reply-to =?iso-8859-1?B?Q2hyaXN0aWFuIE3kY2hsZXI=?= message dated "Tue, 04 Aug 2015 15:49:02 +0200" Date: Tue, 04 Aug 2015 10:58:57 -0400 Message-ID: <26003.1438700337@sss.pgh.pa.us> X-Pg-Spam-Score: -2.1 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org =?iso-8859-1?B?Q2hyaXN0aWFuIE3kY2hsZXI=?= writes: > Here some more detailed examples to show why the behavior of the 3rd group is clearly wrong also according to the specification: What specification are you reading? The POSIX standard for regular expressions doesn't mention non-greedy quantifiers at all. As David says, these examples appear to be following what's stated in http://www.postgresql.org/docs/9.4/static/functions-matching.html#POSIX-MATCHING-RULES The Spencer regex engine we use has a notion of greediness or non-greediness of the entire regex, and further that that takes precedence for determining the overall match length over greediness of individual subexpressions. That behavior might be inconvenient for this particular use-case, but that doesn't make it a bug. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs