Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

StringScanner#rest

() -> ::String
rest → target_substring

Returns the ‘rest’ of the stored string (all after the current position), which is the target substring:

Example
scanner = StringScanner.new('foobarbaz')
scanner.rest # => "foobarbaz"
scanner.pos = 3
scanner.rest # => "barbaz"
scanner.terminate
scanner.rest # => ""
See also #reset #rest_size #pre_match #scan also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0