Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

String#squeeze!

(*::String::selector selectors) -> self?
squeeze!(*selectors) → self or nil

Like String#squeeze, except that:

  • Characters are squeezed in self (not in a copy of self).

  • Returns self if any changes are made, nil otherwise.

Related: See Modifying.

See also #squeeze #start_with? #split #strip also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0