📜  红宝石 | StringScanner charpos函数

📅  最后修改于: 2022-05-13 01:55:26.211000             🧑  作者: Mango

红宝石 | StringScanner charpos函数

StringScanner#charpos() : 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