Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSDI5-00057w-N0 for pgsql-docs@arkaria.postgresql.org; Tue, 04 Jul 2017 02:10:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dSDI4-0003ZJ-He for pgsql-docs@arkaria.postgresql.org; Tue, 04 Jul 2017 02:10:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dSDI3-0003Xc-Qt for pgsql-docs@postgresql.org; Tue, 04 Jul 2017 02:10:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dSDI0-0005Wu-T3 for pgsql-docs@postgresql.org; Tue, 04 Jul 2017 02:10:11 +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 v642A3Fd025896; Mon, 3 Jul 2017 22:10:03 -0400 From: Tom Lane To: srn@coolheads.com cc: pgsql-docs@postgresql.org Subject: Re: can't be both non-capturing and still capture In-reply-to: <20170703204755.27952.9007@wrigleys.postgresql.org> References: <20170703204755.27952.9007@wrigleys.postgresql.org> Comments: In-reply-to srn@coolheads.com message dated "Mon, 03 Jul 2017 20:47:55 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25894.1499134203.1@sss.pgh.pa.us> Date: Mon, 03 Jul 2017 22:10:03 -0400 Message-ID: <25895.1499134203@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org srn@coolheads.com writes: > Here, the whole regexp is non-capturing, right, so how can the result be > reported as shown? No, the outer parens are non-capturing, but the ones inside them still are capturing parens. Perhaps it would clarify matters if you tried it with plain outer parens: =# SELECT regexp_matches('abc01234xyz', '((.*?)(\d+)(.*)){1,1}'); regexp_matches ----------------------------- {abc01234xyz,abc,01234,xyz} (1 row) In this case we get a report from each of the four sets of capturing parens. Or another example: =# SELECT regexp_matches('abc01234xyz', '((?:.*?)(\d+)(.*)){1,1}'); regexp_matches ------------------------- {abc01234xyz,01234,xyz} (1 row) Outer parens capture, first inner set don't, other two inner sets do. regards, tom lane -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs