Related Articles

Related Articles

Ruby | Regexp ===() function
  • Last Updated : 17 Dec, 2019

Regexp#===() : ===() is a Regexp class method which compares the equality of two regular expressions.

Syntax: Regexp.===()

Parameter: Regexp values

Return: true – if two regular expressions has equality otherwise return false

Example #1 :



filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

Regexp === form : false

Regexp === form : false

Regexp === form : false

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

Regexp === form : false

Regexp === form : false

Regexp === form : false

My Personal Notes arrow_drop_up
Recommended Articles
Page :