Skip to content

Commit 71b11fd

Browse files
authored
Document :Perl5 adverb
1 parent d3b6482 commit 71b11fd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/Language/regexes.pod6

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,18 @@ Grammars provide an easy way to override what C«<.ws>» matches:
12731273
When parsing file formats where some whitespace (for example, vertical
12741274
whitespace) is significant, it's advisable to override C<ws>.
12751275
1276+
=head3 Perl 5 compatibility adverb
1277+
1278+
The B<C<:Perl5>> or B<C<:P5>> adverb switch the Regex parsing and matching
1279+
back to the way Perl 5 regexes did behave:
1280+
1281+
so 'hello world' ~~ m:Perl5/^hello (world)/ # OUTPUT: «True␤»
1282+
so 'hello world' ~~ m/^hello (world)/ # OUTPUT: «False␤»
1283+
so 'hello world' ~~ m/^ 'hello ' ('world')/ # OUTPUT: «True␤»
1284+
1285+
The regular behavior is recommended and more idiomatic in Perl 6 of course,
1286+
but the B<C<:Perl5>> adverb can be useful when backwards-compatibility is required.
1287+
12761288
=head2 Matching adverbs
12771289
12781290
In contrast to regex adverbs, which are tied to the declaration of a regex,

0 commit comments

Comments
 (0)