Open In App

Ruby | StringScanner check function

Improve
Improve
Like Article
Like
Save
Share
Report

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

Last Updated : 12 Dec, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads