當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Ruby Regexp casefold?()用法及代碼示例


Regexp#casefold?():casefold?()是一個Regexp類方法,它返回正則表達式的不區分大小寫標誌的值。

用法:Regexp.casefold?()

參數:正則表達式值


返回:正則表達式的不區分大小寫標誌的值

範例1:

# Ruby code for Regexp.casefold?() method 
  
# declaring Regexp value 
reg_a = /a/ 
  
# declaring Regexp value 
reg_b = /geeks/i 
  
# declaring Regexp value 
reg_c = /a/ 
  
  
#  casefold? method 
puts "Regexp casefold? form:#{reg_a.casefold?}\n\n"
  
puts "Regexp casefold? form:#{reg_b.casefold?}\n\n"
  
puts "Regexp casefold? form:#{reg_c.casefold?}\n\n"

輸出:

Regexp casefold? form:false

Regexp casefold? form:true

Regexp casefold? form:false

範例2:

# Ruby code for Regexp.casefold?() method 
  
# declaring Regexp value 
reg_a = /geeks/ 
  
# declaring Regexp value 
reg_b = /problem/ 
  
# declaring Regexp value 
reg_c = /code/i 
  
  
#  casefold? method 
puts "Regexp casefold? form:#{reg_a.casefold?}\n\n"
  
puts "Regexp casefold? form:#{reg_b.casefold?}\n\n"
  
puts "Regexp casefold? form:#{reg_c.casefold?}\n\n"

輸出:

Regexp casefold? form:false

Regexp casefold? form:false

Regexp casefold? form:true



相關用法


注:本文由純淨天空篩選整理自mayank5326大神的英文原創作品 Ruby | Regexp casefold?() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。