红宝石 | StringScanner charpos函数
StringScanner#charpos() : charpos()是一个 StringScanner 类方法,它返回扫描指针的字符位置。
Syntax: StringScanner.charpos()
Parameter: StringScanner values
Return: the character position of the scan pointer
示例 #1:
# Ruby code for StringIO.charpos() method
# loading StringIO
require 'strscan'
# declaring StringIO
c = StringScanner.new("Fri Dec 12 1975 14:39")
# charpos() method
puts "String Scanner charpos form : #{c.charpos()}\n\n"
输出 :
String Scanner charpos form : 0
示例 #2:
# Ruby code for StringIO.charpos() method
# loading StringIO
require 'strscan'
# declaring StringIO
c = StringScanner.new("hellogeeks")
# charpos() method
puts "String Scanner charpos form : #{c.charpos()}\n\n"
输出 :
String Scanner charpos form : 0