instance method
index
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v3.2.22.5Signature
index(needle, offset=0)
Returns the position needle in the string, counting in codepoints. Returns nil if needle isn’t found.
Example:
'Café périferôl'.mb_chars.index('ô') #=> 12 'Café périferôl'.mb_chars.index(/\w/u) #=> 0
Parameters
-
needlereq -
offsetopt = 0
Source
# File activesupport/lib/active_support/multibyte/chars.rb, line 198
def index(needle, offset=0)
index = @wrapped_string.index(needle, offset)
index ? (self.class.u_unpack(@wrapped_string.slice(0...index)).size) : nil
end
Defined in activesupport/lib/active_support/multibyte/chars.rb line 198
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Multibyte::Chars