index(needle, offset=0)
public
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('ô')
'Café périferôl'.mb_chars.index(/\w/u)
# File activesupport/lib/active_support/multibyte/chars.rb, line 149
def index(needle, offset=0)
wrapped_offset = first(offset).wrapped_string.length
index = @wrapped_string.index(needle, wrapped_offset)
index ? (Unicode.u_unpack(@wrapped_string.slice(0...index)).size) : nil
end