Related Articles

Related Articles

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 :



filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

Regexp eql? form : false

Regexp eql? form : true

Regexp eql? form : false

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

Regexp eql? form : false

Regexp eql? form : true

Regexp eql? form : false

My Personal Notes arrow_drop_up
Recommended Articles
Page :