End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Regexp#source
rxp.source → str
re.c
View on GitHub ↗
static VALUE
rb_reg_source(VALUE re)
{
VALUE str;
rb_reg_check(re);
str = rb_str_dup(RREGEXP_SRC(re));
return str;
}
Returns the original string of the pattern.
Example
/ab+c/ix.source #=> "ab+c"
Note that escape sequences are retained as is.
Example
/\x20\+/.source #=> "\\x20\\+"