Skip to content
instance method

String#gsub!

(::Regexp | ::string pattern, ::string | ::hash[::String, ::_ToS] replacement) -> self?
(::Regexp | ::string pattern) -> ::Enumerator[::String, self?]
(::Regexp | ::string pattern) { (::String match) -> ::_ToS } -> self?
gsub!(pattern, replacement) → self or nil
gsub!(pattern) {|match| ... } → self or nil
gsub!(pattern) → an_enumerator

Like String#gsub, except that:

  • Performs substitutions in self (not in a copy of self).

  • Returns self if any characters are removed, nil otherwise.

Related: see Modifying.

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