📜  红宝石 | StringScanner search_full函数

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

红宝石 | StringScanner search_full函数

StringScanner#search_full() : search_full()是一个 StringScanner 方法,它扫描字符串直到模式匹配。

示例 #1:

# Ruby code for StringScanner.search_full() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("Mon Sep 12 2018 14:39")
   
# search_full() method
c.search_full(/\w+/, 2, 3)
  
puts "String Scanner result of c.search_full() form : #{c.pos()}\n\n"
  
# search_full() method
c.search_full(/\s+/, 4, 8)
  
puts "String Scanner result of c.search_full() form : #{c.pos()}\n\n"

输出 :

String Scanner result of c.search_full() form : 3

String Scanner result of c.search_full() form : 4

示例 #2:

# Ruby code for StringScanner.search_full() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("h ello geeks")
   
# search_full() method
c.search_full(/\w+/, 2, 3)
  
puts "String Scanner result of c.search_full() form : #{c.pos()}\n\n"
  
 search_full() method
c.search_full(/\s+/, 4, 8)
  
puts "String Scanner result of c.search_full() form : #{c.pos()}\n\n"

输出 :

String Scanner result of c.search_full() form : 1

String Scanner result of c.search_full() form : 2