红宝石 | StringScanner check_until函数
StringScanner#check_until() : check_until()是一个 StringScanner 类方法,它返回 scan_until 将返回的值,而无需推进扫描指针。
Syntax: StringScanner.check_until()
Parameter: StringScanner values
Return: the value that scan_until would return, without advancing the scan pointer.
示例 #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"
输出 :
String Scanner check_until form : Fri Dec 12 1975
示例 #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"
输出 :
String Scanner check_until form : helloge