mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00

(https://github.com/ruby/strscan/pull/126)
Split off from https://github.com/ruby/ruby/pull/12322
9bee37e0f5
14 lines
340 B
Markdown
14 lines
340 B
Markdown
call-seq:
|
|
pos -> byte_position
|
|
|
|
Returns the integer [byte position][2],
|
|
which may be different from the [character position][7]:
|
|
|
|
```rb
|
|
scanner = StringScanner.new(HIRAGANA_TEXT)
|
|
scanner.string # => "こんにちは"
|
|
scanner.pos # => 0
|
|
scanner.getch # => "こ" # 3-byte character.
|
|
scanner.charpos # => 1
|
|
scanner.pos # => 3
|
|
```
|