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
# File activesupport/lib/active_support/multibyte/chars.rb, line 207 def index(needle, offset=0) index = @wrapped_string.index(needle, offset) index ? (self.class.u_unpack(@wrapped_string.slice(0...index)).size) : nil end