📜  红宝石 |正则表达式 casefold?()函数

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

红宝石 |正则表达式 casefold?()函数

Regexp#casefold?() : casefold?()是一个 Regexp 类方法,它返回正则表达式的不区分大小写标志的值。

示例 #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