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
re.c
View on GitHub ↗
static VALUE
rb_reg_inspect(VALUE re)
{
if (!RREGEXP_PTR(re) || !RREGEXP_SRC(re) || !RREGEXP_SRC_PTR(re)) {
return rb_any_to_s(re);
}
return rb_reg_desc(RREGEXP_SRC_PTR(re), RREGEXP_SRC_LEN(re), re);
}
Returns a nicely-formatted string representation of self:
Example
/ab+c/ix.inspect # => "/ab+c/ix"
Related: Regexp#to_s.