Ruby | StringScanner pos function Last Updated : 10 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report StringScanner#pos() : pos() is a StringScanner class method which returns the byte position of the scan pointer Syntax: StringScanner.pos() Parameter: StringScanner values Return: the byte position of the scan pointer Example #1 : Ruby # Ruby code for StringScanner.pos() method # loading StringScanner require 'strscan' # declaring StringScanner c = StringScanner.new("Mon Sep 12 2018 14:39") # pos() method puts "String Scanner pos form : #{c.pos()}\n\n" c.terminate() # pos() method puts "String Scanner pos form : #{c.pos()}\n\n" Output : String Scanner pos form : 0 String Scanner pos form : 21 Example #2 : Ruby # Ruby code for StringScanner.pos() method # loading StringScanner require 'strscan' # declaring StringScanner c = StringScanner.new("hellogeeks") # pos() method puts "String Scanner pos form : #{c.pos()}\n\n" c.terminate() # pos() method puts "String Scanner pos form : #{c.pos()}\n\n" Output : String Scanner pos form : 0 String Scanner pos form : 10 Comment More infoAdvertise with us Next Article Ruby | StringScanner peek function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby String Scanner-class Similar Reads Ruby | StringScanner pos= function StringScanner#pos=() : pos=() is a StringScanner class method which sets the byte position of the scan pointer. Syntax: StringScanner.pos=() Parameter: StringScanner values Return: sets the byte position of the scan pointer. Example #1 : Ruby # Ruby code for StringScanner.pos=() method # loading Str 1 min read Ruby | StringScanner rest function 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 : Ruby # R 1 min read Ruby | StringScanner peep function StringScanner#peep() : peep() is a StringScanner class method which returns a string corresponding to string[pos, len]. Syntax: StringScanner.peep() Parameter: StringScanner values len - length of the string value Return: a string corresponding to string[pos, len] Example #1 : Ruby # Ruby code for S 1 min read Ruby | StringScanner rest? function StringScanner#rest?() : rest?() is a StringScanner class method which checks if there is more data in the string Syntax: StringScanner.rest?() Parameter: StringScanner values Return: true if there is more data in the string otherwise return false Example #1 : Ruby # Ruby code for StringScanner.rest? 1 min read Ruby | StringScanner peek function StringScanner#peek() : peek() is a StringScanner class method which returns a string corresponding to string[pos, len]. Syntax: StringScanner.peek() Parameter: StringScanner values len - length of the string value Return: a string corresponding to string[pos, len] Example #1 : Ruby # Ruby code for S 1 min read Ruby | StringScanner pointer function StringScanner#pointer() : pointer() is a StringScanner class method which returns the byte position of the scan pointer Syntax: StringScanner.pointer() Parameter: StringScanner values Return: the byte position of the scan pointer Example #1 : Ruby # Ruby code for StringScanner.pointer() method # loa 1 min read Like