Skip to content
instance method

StringScanner#reset

() -> void
reset → self

Sets both byte position and character position to zero, and clears match values; returns self:

Example
scanner = StringScanner.new('foobarbaz')
scanner.exist?(/bar/)          # => 6
scanner.reset                  # => #<StringScanner 0/9 @ "fooba...">
put_situation(scanner)
# Situation:
#   pos:       0
#   charpos:   0
#   rest:      "foobarbaz"
#   rest_size: 9
# => nil
match_values_cleared?(scanner) # => true
See also #pre_match #rest #post_match #rest_size also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0