rindex

str.rindex(substring [, 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
doc_ruby_on_rails
2015-05-15 18:28:02
Comments
Leave a Comment

Please login to continue.