rindex(needle, offset=nil)
Returns the position needle in the string, counting in codepoints, searching backward from offset or the end of the string. Returns nil if needle isn’t found.
Example:
'Café périferôl'.mb_chars.rindex('é') #=> 6 'Café périferôl'.mb_chars.rindex(/\w/u) #=> 13
# File activesupport/lib/active_support/multibyte/chars.rb, line 211 def rindex(needle, offset=nil) offset ||= length wrapped_offset = self.first(offset).wrapped_string.length index = @wrapped_string.rindex(needle, wrapped_offset) index ? (self.class.u_unpack(@wrapped_string.slice(0...index)).size) : nil end