Skip to content

Commit

Permalink
Added doc for Str.indices. eater++
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Olof Hendig committed May 14, 2017
1 parent e05dc46 commit 3eaf7f2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions doc/Type/Str.pod6
Expand Up @@ -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<List> 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)
Expand Down

0 comments on commit 3eaf7f2

Please sign in to comment.