mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
(https://github.com/ruby/strscan/pull/203) They don't work in included markdown and also need a leading `:` <img width="791" height="442" alt="grafik" src="https://github.com/user-attachments/assets/eca5d4c2-9597-4c58-a0cc-a4e2c9109992" /> https://github.com/ruby/strscan/commit/b504b3b0ad
425 B
425 B
Returns the [character position][7] (initially zero), which may be different from the [byte position][2] given by method #pos:
scanner = StringScanner.new(HIRAGANA_TEXT)
scanner.string # => "こんにちは"
scanner.getch # => "こ" # 3-byte character.
scanner.getch # => "ん" # 3-byte character.
put_situation(scanner)
# Situation:
# pos: 6
# charpos: 2
# rest: "にちは"
# rest_size: 9