Ruby | StringScanner pointer= function
Last Updated :
10 Dec, 2019
StringScanner#pointer=() : pointer=() is a StringScanner class method which sets the byte position of the scan pointer.
Syntax: StringScanner.pointer=()
Parameter: StringScanner values
Return: sets the byte pointerition of the scan pointer.
Example #1 :
require 'strscan'
c = StringScanner. new ( "Mon Sep 12 2018 14:39" )
c.pointer = 2
puts "#{c.rest}\n\n"
c.pointer = 20
puts "#{c.rest}\n\n"
|
Output :
n Sep 12 2018 14:39
9
Example #2 :
require 'strscan'
c = StringScanner. new ( "hellogeeks" )
c.pointer = 2
puts "#{c.rest}\n\n"
c.pointer = 7
puts "#{c.rest}\n\n"
|
Output :
llogeeks
eks
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...