Ruby | Regexp ==() function
Last Updated :
17 Dec, 2019
Regexp#==() : ==() is a Regexp class method which compares two regular expressions.
Syntax: Regexp.==()
Parameter: Regexp values
Return: true – if two regular expressions are equal otherwise return false
Example #1 :
reg_a = /a/
reg_b = /geeks/
reg_c = /a/
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"
|
Output :
Regexp == form : false
Regexp == form : false
Regexp == form : true
Example #2 :
reg_a = /geeks/
reg_b = /problem/
reg_c = /code/
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"
|
Output :
Regexp == form : false
Regexp == form : true
Regexp == form : false
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...