Ruby | StringScanner rest_size function
Last Updated :
10 Dec, 2019
StringScanner#rest_size() : rest_size() is a StringScanner class method which returns the size of the bytes after the string position.
Syntax: StringScanner.rest_size()
Parameter: StringScanner values
Return: the size of the bytes after the string position.
Example #1 :
require 'strscan'
c = StringScanner. new ( "Mon Sep 12 2018 14:39" )
c.pos = 2
puts "String Scanner rest_size form : #{c.rest_size}\n\n"
c.pos = 7
puts "String Scanner rest_size form : #{c.rest_size}\n\n"
|
Output :
String Scanner rest_size form : 19
String Scanner rest_size form : 14
Example #2 :
require 'strscan'
c = StringScanner. new ( "hellogeeks" )
c.pos = 2
puts "String Scanner rest_size form : #{c.rest_size}\n\n"
c.pos = 7
puts "String Scanner rest_size form : #{c.rest_size}\n\n"
|
Output :
String Scanner rest_size form : 8
String Scanner rest_size form : 3
Share your thoughts in the comments
Please Login to comment...