Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
String#gsub!
gsub!(pattern, replacement) → self or nil
gsub!(pattern) {|match| ... } → self or nil
gsub!(pattern) → an_enumerator
string.c
View on GitHub ↗
static VALUE
rb_str_gsub_bang(int argc, VALUE *argv, VALUE str)
{
str_modify_keep_cr(str);
return str_gsub(argc, argv, str, 1);
}
Performs the specified substring replacement(s) on self; returns self if any replacement occurred, nil otherwise.
See Substitution Methods.
Returns an Enumerator if no replacement and no block given.
Related: String#sub, String#gsub, String#sub!.