当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。