instance method
rindex
Ruby on Rails 3.2.22.5
Since v2.3.18 Last seen in v3.2.22.5Signature
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
Parameters
-
needlereq -
offsetopt = nil
Source
# File activesupport/lib/active_support/multibyte/chars.rb, line 163
def rindex(needle, offset=nil)
offset ||= length
wrapped_offset = first(offset).wrapped_string.length
index = @wrapped_string.rindex(needle, wrapped_offset)
index ? (Unicode.u_unpack(@wrapped_string.slice(0...index)).size) : nil
end
Defined in activesupport/lib/active_support/multibyte/chars.rb line 163
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Multibyte::Chars