Go back Ruby & Ruby on Rails tricks

String

Squish

replace multiple white spaces with one
" Bring   ME \n the   Horizon".squish
# => "Bring ME the Horizon"

%{ Multi-line
   string }.squish                   # => "Multi-line string"

" foo   bar    \n   \t   boo".squish # => "foo bar boo"