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 :
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 : false
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 : false
Regexp === form : false
Share your thoughts in the comments
Please Login to comment...