Related Articles

Related Articles

Ruby | StringScanner rest function
  • Last Updated : 10 Dec, 2019

StringScanner#rest() : rest() is a StringScanner class method which returns the “rest” of the string (i.e. everything after the scan pointer).

Syntax: StringScanner.rest()

Parameter: StringScanner values

Return: the “rest” of the string (i.e. everything after the scan pointer).

Example #1 :



filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for StringScanner.rest() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("Mon Sep 12 2018 14:39")
  
# rest() method
c.pos = 2
puts "String Scanner rest form : #{c.rest}\n\n"
  
# rest() method
c.pos = 7
puts "String Scanner rest form : #{c.rest}\n\n"

chevron_right


Output :

String Scanner rest form : n Sep 12 2018 14:39

String Scanner rest form :  12 2018 14:39

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for StringScanner.rest() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("hellogeeks")
  
# rest() method
c.pos = 2
puts "String Scanner rest form : #{c.rest}\n\n"
  
# rest() method
c.pos = 7
puts "String Scanner rest form : #{c.rest}\n\n"

chevron_right


Output :

String Scanner rest form : llogeeks

String Scanner rest form : eks

My Personal Notes arrow_drop_up
Recommended Articles
Page :