Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

String#gsub!

str.gsub!(pattern, replacement) → str or nil
str.gsub!(pattern, hash) → str or nil
str.gsub!(pattern) {|match| block } → str or nil
str.gsub!(pattern) → an_enumerator

Performs the substitutions of String#gsub in place, returning str, or nil if no substitutions were performed. If no block and no replacement is given, an enumerator is returned instead.

See also #gsub #hash #grapheme_clusters #hex also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1