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 :
require 'strscan'
c = StringScanner. new ( "Mon Sep 12 2018 14:39" )
c.pos = 2
puts "String Scanner rest form : #{c.rest}\n\n"
c.pos = 7
puts "String Scanner rest form : #{c.rest}\n\n"
|
Output :
String Scanner rest form : n Sep 12 2018 14:39
String Scanner rest form : 12 2018 14:39
Example #2 :
require 'strscan'
c = StringScanner. new ( "hellogeeks" )
c.pos = 2
puts "String Scanner rest form : #{c.rest}\n\n"
c.pos = 7
puts "String Scanner rest form : #{c.rest}\n\n"
|
Output :
String Scanner rest form : llogeeks
String Scanner rest form : eks
Share your thoughts in the comments
Please Login to comment...