This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlre: Add note that nested (?>...) are not no-ops
authorKarl Williamson <khw@cpan.org>
Tue, 20 Feb 2018 03:52:29 +0000 (20:52 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 20 Feb 2018 04:04:12 +0000 (21:04 -0700)
pod/perlre.pod

index 29082a6..0c6ef15 100644 (file)
@@ -2248,6 +2248,18 @@ to inside of one of these constructs. The following equivalences apply:
     PAT?+               (?>PAT?)
     PAT{min,max}+       (?>PAT{min,max})
 
+Nested C<(?E<gt>...)> constructs are not no-ops, even if at first glance
+they might seem to be.  This is because the nested C<(?E<gt>...)> can
+restrict internal backtracking that otherwise might occur.  For example,
+
+ "abc" =~ /(?>a[bc]*c)/
+
+matches, but
+
+ "abc" =~ /(?>a(?>[bc]*)c)/
+
+does not.
+
 The alphabetic form (C<(*atomic:...)>) is experimental; using it
 yields a warning in the C<experimental::alpha_assertions> category.