instance method
squish!
Ruby on Rails edge
Since v3.0.20Signature
squish!()
Performs a destructive squish. See String#squish.
str = " foo bar \n \t boo"
str.squish! # => "foo bar boo"
str # => "foo bar boo"
Source
# File activesupport/lib/active_support/core_ext/string/filters.rb, line 27
def squish!
# Search for two or more `[[:space:]]` OR a single
# [[:space:]] that isn't `" "`.
gsub!(/([[:space:]]{2,}|[[[:space:]]&&[^ ]])/, " ")
strip!
self
end
Defined in activesupport/lib/active_support/core_ext/string/filters.rb line 27
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in String