Skip to content
Related Articles

Related Articles

Improve Article

Ruby | Regexp casefold?() function

  • Last Updated : 17 Dec, 2019
Geek Week

Regexp#casefold?() : casefold?() is a Regexp class method which returns the value of the case-insensitive flag of regular expressions.

Syntax: Regexp.casefold?()

Parameter: Regexp values

Return: value of the case-insensitive flag of regular expressions

Example #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"

Output :

Regexp casefold? form : false

Regexp casefold? form : true

Regexp casefold? form : false

Example #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"

Output :

Regexp casefold? form : false

Regexp casefold? form : false

Regexp casefold? form : true

My Personal Notes arrow_drop_up
Recommended Articles
Page :