Ruby | StringScanner pos function
Last Updated :
10 Dec, 2019
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 :
require 'strscan'
c = StringScanner. new ( "Mon Sep 12 2018 14:39" )
puts "String Scanner pos form : #{c.pos()}\n\n"
c.terminate()
puts "String Scanner pos form : #{c.pos()}\n\n"
|
Output :
String Scanner pos form : 0
String Scanner pos form : 21
Example #2 :
require 'strscan'
c = StringScanner. new ( "hellogeeks" )
puts "String Scanner pos form : #{c.pos()}\n\n"
c.terminate()
puts "String Scanner pos form : #{c.pos()}\n\n"
|
Output :
String Scanner pos form : 0
String Scanner pos form : 10
Share your thoughts in the comments
Please Login to comment...