Flowdock
method

charpos

Importance_1
v2_6_3 - Show latest stable - 0 notes - Class: StringScanner
charpos() public

Returns the character position of the scan pointer. In the ‘reset’ position, this value is zero. In the ‘terminated’ position (i.e. the string is exhausted), this value is the size of the string.

In short, it’s a 0-based index into the string.

s = StringScanner.new("abcädeföghi")
s.charpos           # -> 0
s.scan_until(/ä/)   # -> "abcä"
s.pos               # -> 5
s.charpos           # -> 4
Show source
Register or log in to add new notes.