This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Support for nocapture regexp flag /n
authorMatthew Horsfall (alh) <wolfsage@gmail.com>
Thu, 23 Oct 2014 00:56:47 +0000 (20:56 -0400)
committerMatthew Horsfall <wolfsage@gmail.com>
Sun, 28 Dec 2014 14:34:03 +0000 (09:34 -0500)
commit41d7c59e80e58de2b82e3759c8de14ee8aedb564
tree857d2ef14a82e87a9a37349773cf3906a23466ac
parentfde14af1e494660628714463be39d015ab768ff4
Support for nocapture regexp flag /n

This flag will prevent () from capturing and filling in $1, $2, etc...

Named captures will still work though, and if used will cause $1, $2, etc...
to be filled in *only* within named groups.

The motivation behind this is to allow the common construct of:

  /(?:b|c)a(?:t|n)/

To be rewritten more cleanly as:

  /(b|c)a(t|n)/n

When you want grouping but no memory penalty on captures.

You can also use ?n inside of a () directly to avoid capturing, and
?-n inside of a () to negate its effects if you want to capture.
MANIFEST
dump.c
ext/re/re.pm
regcomp.c
regexp.h
t/re/reg_nocapture.t [new file with mode: 0644]