Documentation for routine rindex assembled from the following pages:

Class: Str §

From Str

(Str) routine rindex §

multi method rindex(Str:D: Str:D $needle --> Int:D)
multi method rindex(Str:D: Str:D $needleInt:D $pos --> Int:D)
multi method rindex(Str:D: @needles --> Int:D)

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:D $sCool:D $needle --> Int:D)
multi sub rindex(Cool:D $sCool:D $needleCool:D $pos --> Int:D)
multi method rindex(Cool:D: Cool:D $needle --> Int:D)
multi method rindex(Cool:D: Cool:D $needleCool:D $pos --> Int:D)

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.