Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Ruby | Regexp eql?() function

  • Last Updated : 17 Dec, 2019

Regexp#eql?() : eql?() is a Regexp class method which matches the character in two regular expression.

Syntax: Regexp.eql?()

Parameter: Regexp values

Return: true – if two regular expressions matches string otherwise return false

Example #1 :






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

Output :

Regexp eql? form : false

Regexp eql? form : true

Regexp eql? form : false

Example #2 :




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

Output :

Regexp eql? form : false

Regexp eql? form : true

Regexp eql? form : false




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!