X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/33be4c6111bea619c1662d201ad9e3914c2013e5..12e1284a67e5e3404c704c3f864749fd9f04c7c4:/pod/perlre.pod
diff --git a/pod/perlre.pod b/pod/perlre.pod
index ff8cb18..cc71707 100644
--- a/pod/perlre.pod
+++ b/pod/perlre.pod
@@ -7,60 +7,351 @@ perlre - Perl regular expressions
This page describes the syntax of regular expressions in Perl.
-If you haven't used regular expressions before, a quick-start
-introduction is available in L, C, C
@@ -1000,7 +1299,8 @@ X
X
Backslashed metacharacters in Perl are alphanumeric, such as C<\b>,
C<\w>, C<\n>. Unlike some other regular expression languages, there
are no backslashed symbols that aren't alphanumeric. So anything
-that looks like \\, \(, \), \[, \], \{, or \} is always
+that looks like C<\\>, C<\(>, C<\)>, C<\[>, C<\]>, C<\{>, or C<\}> is
+always
interpreted as a literal character, not a metacharacter. This was
once used in a common idiom to disable or quote the special meanings
of regular expression metacharacters in a string that you want to
@@ -1009,9 +1309,9 @@ use for a pattern. Simply quote all non-"word" characters:
$pattern =~ s/(\W)/\\$1/g;
(If C , and C modifiers are special in
-that they can only be enabled, not disabled, and the C, C modifier is special in that its presence
+Note also that the C<"p"> modifier is special in that its presence
anywhere in a pattern has a global effect.
-=item C<(?:pattern)>
+Having zero modifiers makes this a no-op (so why did you specify it,
+unless it's generated code), and starting in v5.30, warns under L })>
X<(?{})> X
+switch. If I
is put into the special variable C<$^R>. This happens immediately, so
-C<$^R> can be used from other C<(?{ code })> assertions inside the same
+C<$^R> can be used from other C<(?{ I
})> assertions inside the same
regular expression.
The assignment to C<$^R> above is properly localized, so the old
value of C<$^R> is restored if the assertion is backtracked; compare
-L<"Backtracking">.
+L"Backtracking">.
Note that the special variable C<$^N> is particularly useful with code
blocks to capture the results of submatches in variables without having to
@@ -1457,7 +1908,7 @@ keep track of the number of nested parentheses. For example:
print "color = $color, animal = $animal\n";
-=item C<(??{ code })>
+=item C<(??{ I
})>
X<(??{})>
X
})> code block as described above, except that
its return value, rather than being assigned to C<$^R>, is treated as a
pattern, compiled if it's a string (or used as-is if its a qr// object),
then matched as if it were inserted instead of this construct.
@@ -1485,11 +1936,11 @@ pattern captures "A";
Note that this means that there is no way for the inner pattern to refer
to a capture group defined outside. (The code block itself can use C<$1>,
-etc., to refer to the enclosing pattern's capture groups.) Thus, although
+I
})> except that it does not involve executing any
code or potentially compiling a returned pattern string; instead it treats
the part of the current pattern contained within a specified capture group
as an independent pattern that must match at the current position. Also
-different is the treatment of capture buffers, unlike C<(??{ code })>
-recursive patterns have access to their callers match state, so one can
+different is the treatment of capture buffers, unlike C<(??{ I
})>
+recursive patterns have access to their caller's match state, so one can
use backreferences safely.
I
})>
Treats the return value of the code block as the condition.
+Full syntax: C<< (?(?{ I
})I