quote(...)
public
Escapes any characters that would have special meaning in a regular
expression. Returns a new escaped
string, or self if no characters are escaped. For any string,
Regexp.escape(str)=~str will be true.
Regexp.escape('\\*?{}.')
Show source
/*
* call-seq:
* Regexp.escape(str) => a_str
* Regexp.quote(str) => a_str
*
* Escapes any characters that would have special meaning in a regular
* expression. Returns a new escaped string, or self if no characters are
* escaped. For any string,
* <code>Regexp.escape(<i>str</i>)=~<i>str</i></code> will be true.
*
* Regexp.escape('\\*?{}.')
*/
static VALUE
rb_reg_s_quote(argc, argv)
int argc;
VALUE *argv;
{
VALUE str, kcode;
int kcode_saved = reg_kcode;
rb_scan_args(argc, argv, "11", &str, &kcode);
if (!NIL_P(kcode)) {
rb_set_kcode(StringValuePtr(kcode));
curr_kcode = reg_kcode;
reg_kcode = kcode_saved;
}
StringValue(str);
str = rb_reg_quote(str);
rb_kcode_reset_option();
return str;
}