Open In App

Ruby | StringScanner check_until function

Last Updated : 12 Dec, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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

Syntax: StringScanner.check_until()

Parameter: StringScanner values

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

Example #1 :




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


Output :

String Scanner check_until form : Fri Dec 12 1975

Example #2 :




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


Output :

String Scanner check_until form : helloge

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads