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#eql?

rxp.eql?(other_rxp) → true or false

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 #encoding #fixed_encoding? #casefold? #hash also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0