Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Document $ regex anchor
  • Loading branch information
zoffixznet committed Jan 11, 2016
1 parent 273ffa8 commit 7cb83fb
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions doc/Language/regexes.pod
Expand Up @@ -422,15 +422,26 @@ match.
Anchors need to match successfully in order for the whole regex to match but
they do not use up characters while matching.
=head2 X«C<^>, Start of String|regex,^»
=head2 X«C<^>, Start of String and C<$>, End of String|regex,^;regex,$»
The C<^> assertion only matches at the start of the string.
The C<^> assertion only matches at the start of the string:
say so 'properly' ~~ /perl/; # True
say so 'properly' ~~ / perl/; # True
say so 'properly' ~~ /^ perl/; # False
say so 'perly' ~~ /^ perl/; # True
say so 'perl' ~~ /^ perl/; # True
The C<$> assertion only matches at the end of the string:
say so 'use perl' ~~ / perl /; # True
say so 'use perl' ~~ / perl $/; # True
say so 'perly' ~~ / perl $/; # False
You can, of course, combine both anchors:
say so 'use perl' ~~ /^ perl $/; # False
say so 'perl' ~~ /^ perl $/; # True
=head2 X«C<^^>, Start of Line and C<$$>, End of Line|regex,^^;regex,$$»
The C<^^> assertion matches at the start of a logical line. That is, either
Expand Down

0 comments on commit 7cb83fb

Please sign in to comment.