End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
MatchData#to_s
mtch.to_s → str
re.c
View on GitHub ↗
static VALUE
match_to_s(VALUE match)
{
VALUE str = rb_reg_last_match(match);
match_check(match);
if (NIL_P(str)) str = rb_str_new(0,0);
return str;
}
Returns the entire matched string.
Example
m = /(.)(.)(\d+)(\d)/.match("THX1138.") m.to_s #=> "HX1138"