sub(...)
public
Equivalent to $_.sub(args), except
that $_ will be updated if substitution occurs.
Show source
/*
* call-seq:
* sub(pattern, replacement) => $_
* sub(pattern) { block } => $_
*
* Equivalent to <code>$_.sub(<i>args</i>)</code>, except that
* <code>$_</code> will be updated if substitution occurs.
*/
static VALUE
rb_f_sub(argc, argv)
int argc;
VALUE *argv;
{
VALUE str = rb_str_dup(uscore_get());
if (NIL_P(rb_str_sub_bang(argc, argv, str)))
return str;
rb_lastline_set(str);
return str;
}