Method: String#rindex
- Defined in:
- string.c
#rindex(substring[, fixnum]) ⇒ Fixnum? #rindex(fixnum[, fixnum]) ⇒ Fixnum? #rindex(regexp[, fixnum]) ⇒ Fixnum?
Returns the index of the last occurrence of the given substring, character (fixnum), 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(101) #=> 1
"hello".rindex(/[aeiou]/, -2) #=> 1
1214 1215 1216 |
# File 'string.c', line 1214 static VALUE rb_str_rindex_m(argc, argv, str) int argc; |