summaryrefslogtreecommitdiff
path: root/doc/strscan/methods/get_pos.md
blob: 81bbb2345e9268e366d6758474f2532c815c77b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
```