Documentation for routine rindex assembled from the following pages:
Class: Str §
From Str
(Str) routine rindex §
multi method rindex(Str: Str --> Int)multi method rindex(Str: Str , Int --> Int)multi method rindex(Str: --> Int)
Returns the last position of $needle in the string not after $pos. Returns Nil if $needle wasn't found.
Since Rakudo version 2020.05, rindex accepts a list of needles to search the string with, and return the highest index found or Nil.
Examples:
say "aardvark".rindex: "a"; # OUTPUT: «5» say "aardvark".rindex: "a", 0; # OUTPUT: «0 say "aardvark".rindex: "t"; # OUTPUT: «Nil» say "aardvark".rindex: <d v k>; # OUTPUT: «7»
Other forms of rindex, including subs, are inherited from Cool.
Class: Cool §
From Cool
(Cool) routine rindex §
Defined as:
multi sub rindex(Cool , Cool --> Int)multi sub rindex(Cool , Cool , Cool --> Int)multi method rindex(Cool: Cool --> Int)multi method rindex(Cool: Cool , Cool --> Int)
Coerces the first two arguments (including the invocant in method form) to Str and $pos to Int, and returns the last position of $needle in the string not after $pos. Returns Nil if $needle wasn't found.
See the documentation in type Str for examples.