Ruby StringScanner charpos函数
StringScanner#charpos() : charpos()是StringScanner类的一个方法,用于返回扫描指针的字符位置。
语法。StringScanner.charpos()
参数。StringScanner的值
返回:扫描指针的字符位置
例子 #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