Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Regexp#==

rxp == other_rxp → true or false

Alias of #eql?

Equality—Two regexps are equal if their patterns are identical, they have the same character set code, and their casefold? values are the same.

Example
/abc/  == /abc/x   #=> false
/abc/  == /abc/i   #=> false
/abc/  == /abc/u   #=> false
/abc/u == /abc/n   #=> false
See also #eql? .union #=== .try_convert also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0