Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Regexp#inspect

inspect → string

Returns a nicely-formatted string representation of self:

Example
/ab+c/ix.inspect # => "/ab+c/ix"

Related: Regexp#to_s.

See also #hash #match #fixed_encoding? #match? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0