From 3eaf7f2df8c7ba11a4b9bbf8455efb53f5f16594 Mon Sep 17 00:00:00 2001 From: Jan-Olof Hendig Date: Sun, 14 May 2017 20:49:24 +0200 Subject: [PATCH] Added doc for Str.indices. eater++ --- doc/Type/Str.pod6 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc/Type/Str.pod6 b/doc/Type/Str.pod6 index 9a5aaf977..5d75b3600 100644 --- a/doc/Type/Str.pod6 +++ b/doc/Type/Str.pod6 @@ -162,6 +162,26 @@ Examples: say rindex "Camelia is a butterfly", "a"; # OUTPUT: «11␤» say rindex "Camelia is a butterfly", "a", 10; # OUTPUT: «6␤» +=head2 method indices + +Defined as: + + multi method indices(Str:D: Str:D $needle, :$overlap --> List:D) + multi method indices(Str:D: Str:D $needle, Int:D $start, :$overlap --> List:D) + +Searches for all occurances of C<$needle> in the string starting from position +C<$start>, or zero if it is not specified, and returns a C with all offsets +in the string where C<$needle> was found, or an empty list if it was not found. + +If the optional parameter C<:overlap> is specified the search continues from the +index directly following the previous match, otherwise the search will continue +after the previous match. + + say "banana".indices("a"); # OUTPUT: «(1 3 5)␤» + say "banana".indices("ana"); # OUTPUT: «(1)␤» + say "banana".indices("ana", :overlap); # OUTPUT: «(1 3)␤» + say "banana".indices("ana", 2); # OUTPUT: «(3)␤» + =head2 method match method match($pat, :continue(:$c), :pos(:$p), :global(:$g), :overlap(:$ov), :exhaustive(:$ex), :st(:$nd), :rd(:$th), :$nth, :$x --> Match)