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