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

MatchData#to_s

mtch.to_s → str

Returns the entire matched string.

Example
m = /(.)(.)(\d+)(\d)/.match("THX1138.")
m.to_s   #=> "HX1138"
See also #to_a #values_at #string also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0