regex adverb :pos

Documentation for regex adverb :pos assembled from the following types:

language documentation Regexes

From Regexes

(Regexes) regex adverb :pos

Anchor the match at a specific position in the string:

given 'abcdef' {
    my $match = m:pos(2)/.*/;
    say $match.from;        # OUTPUT: «2␤» 
    say ~$match;            # OUTPUT: «cdef␤» 

:p is shorthand for :pos.

Note: unlike :continue, a match anchored with :pos() will fail, instead of attempting to match further down the string:

say "abcdefg" ~~ m:c(3)/e.+/# OUTPUT: «「efg」␤» 
say "abcdefg" ~~ m:p(3)/e.+/# OUTPUT: «False␤»