StringScanner#check():check()是StringScanner類方法,該方法返回掃描將返回的值,而無需提前掃描指針
用法:StringScanner.check()
參數:StringScanner值
返回:掃描將返回的值,而無需提前掃描指針
示例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
相關用法
- Ruby StringScanner eos?用法及代碼示例
- Ruby StringScanner pos用法及代碼示例
- Ruby StringScanner pos=用法及代碼示例
- Ruby StringScanner peek用法及代碼示例
- Ruby StringScanner matched_size用法及代碼示例
- Ruby StringScanner peep用法及代碼示例
- Ruby StringScanner matched用法及代碼示例
- Ruby StringScanner match?用法及代碼示例
- Ruby StringScanner exist?用法及代碼示例
- Ruby StringScanner unscan用法及代碼示例
- Ruby StringScanner matched?用法及代碼示例
- Ruby StringScanner terminate用法及代碼示例
- Ruby StringScanner pointer用法及代碼示例
- Ruby StringScanner string用法及代碼示例
- Ruby StringScanner scan_full用法及代碼示例
注:本文由純淨天空篩選整理自mayank5326大神的英文原創作品 Ruby | StringScanner check function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。