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#regexp

mtch.regexp → regexp

Returns the regexp.

Example
m = /a.*b/.match("abc")
m.regexp #=> /a.*b/
See also #pre_match #size #post_match #string also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0