pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
can't be both non-capturing and still capture
2+ messages / 2 participants
[nested] [flat]

* can't be both non-capturing and still capture
@ 2017-07-03 20:47 srn@coolheads.com
  2017-07-04 02:10 ` Re: can't be both non-capturing and still capture Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: srn@coolheads.com @ 2017-07-03 20:47 UTC (permalink / raw)
  To: pgsql-docs

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.6/static/index.html
Description:

In postgresql-doc-9.5/html/functions-matching.html#POSIX-MATCHING-RULES:

<PRE
CLASS="SCREEN"
>SELECT regexp_matches('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
<I
CLASS="LINEANNOTATION"
>Result: </I
><SAMP
CLASS="COMPUTEROUTPUT"
>{abc,01234,xyz}</SAMP
></PRE
>

Here, the whole regexp is non-capturing, right, so how can the result be
reported as shown?

The previous two warmup examples do not have the surrounding
non-capturing-group markup.  Looks to me like that markup should not appear
here, either.

-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: can't be both non-capturing and still capture
  2017-07-03 20:47 can't be both non-capturing and still capture srn@coolheads.com
@ 2017-07-04 02:10 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2017-07-04 02:10 UTC (permalink / raw)
  To: srn@coolheads.com; +Cc: pgsql-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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2017-07-04 02:10 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-07-03 20:47 can't be both non-capturing and still capture srn@coolheads.com
2017-07-04 02:10 ` Tom Lane <tgl@sss.pgh.pa.us>

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