pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: srn@coolheads.com
Cc: pgsql-docs@postgresql.org
Subject: Re: can't be both non-capturing and still capture
Date: Mon, 03 Jul 2017 22:10:03 -0400
Message-ID: <25895.1499134203@sss.pgh.pa.us> (raw)
In-Reply-To: <20170703204755.27952.9007@wrigleys.postgresql.org>
References: <20170703204755.27952.9007@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-docs>

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



view thread (2+ messages)

Message-ID: <25895.1499134203@sss.pgh.pa.us>
Permalink:  ../25895.1499134203@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25895.1499134203@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, srn@coolheads.com
  Subject: Re: can't be both non-capturing and still capture
  In-Reply-To: <25895.1499134203@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox