ruby/doc/strscan/methods/get_pos.md
Hiroshi SHIBATA 3eda59e975
Sync strscan HEAD again.
https://github.com/ruby/strscan/pull/99 split document with multi-byte
chars.
2024-06-04 12:40:08 +09:00

338 B

call-seq: pos -> byte_position

Returns the integer [byte position][2], which may be different from the [character position][7]:

scanner = StringScanner.new(HIRAGANA_TEXT)
scanner.string  # => "こんにちは"
scanner.pos     # => 0
scanner.getch   # => "こ" # 3-byte character.
scanner.charpos # => 1
scanner.pos     # => 3