Skip to content
Related Articles

Related Articles

Ruby | StringScanner check function

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 12 Dec, 2019

StringScanner#check() : check() is a StringScanner class method which returns the value that scan would return, without advancing the scan pointer

Syntax: StringScanner.check()

Parameter: StringScanner values

Return: the value that scan would return, without advancing the scan pointer

Example #1 :




# Ruby code for StringIO.check() method
  
# loading StringIO
require 'strscan'
  
# declaring StringIO 
c = StringScanner.new("Fri Dec 12 1975 14:39")
  
# check() method
puts "String Scanner check form : #{c.check /Fri/}\n\n"

Output :

String Scanner check form : Fri

Example #2 :




# Ruby code for StringIO.check() method
  
# loading StringIO
require 'strscan'
  
# declaring StringIO 
c = StringScanner.new("hellogeeks")
  
# check() method
puts "String Scanner check form : #{c.check /hel/}\n\n"

Output :

String Scanner check form : hel

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!