str.rindex(substring [, fixnum]) â fixnum or nil
str.rindex(regexp [, fixnum]) â fixnum or nil
str.rindex(regexp [, fixnum]) â fixnum or nil
Instance Public methods
Returns the index of the last occurrence of the given substring or
pattern (regexp) in str. Returns nil
if not
found. If the second parameter is present, it specifies the position in the
string to end the searchâcharacters beyond this point will not be
considered.
"hello".rindex('e') #=> 1 "hello".rindex('l') #=> 3 "hello".rindex('a') #=> nil "hello".rindex(?e) #=> 1 "hello".rindex(/[aeiou]/, -2) #=> 1
Please login to continue.