Ruby Regexp casefold?()函数

Ruby Regexp casefold?()函数

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

语法。Regexp.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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程