Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
MatchData#eql?
(::MatchData other) -> bool
(untyped) -> false
self == other -> true or false
re.c
View on GitHub ↗
static VALUE
match_equal(VALUE match1, VALUE match2)
{
if (match1 == match2) return Qtrue;
if (!RB_TYPE_P(match2, T_MATCH)) return Qfalse;
if (!RMATCH(match1)->regexp || !RMATCH(match2)->regexp) return Qfalse;
if (!rb_str_equal(RMATCH(match1)->str, RMATCH(match2)->str)) return Qfalse;
if (!rb_reg_equal(match_regexp(match1), match_regexp(match2))) return Qfalse;
int num_regs = RMATCH_NREGS(match1);
if (num_regs != RMATCH_NREGS(match2)) return Qfalse;
if (memcmp(RMATCH_BEG_PTR(match1), RMATCH_BEG_PTR(match2), num_regs * sizeof(OnigPosition))) return Qfalse;
if (memcmp(RMATCH_END_PTR(match1), RMATCH_END_PTR(match2), num_regs * sizeof(OnigPosition))) return Qfalse;
return Qtrue;
}
Returns whether other is another MatchData object whose target string, regexp, match, and captures are the same as self.