Ruby/String/Strip
Материал из Wiki.crossplatform.ru
Версия от 17:56, 13 сентября 2010; ViGOur (Обсуждение | вклад)
Содержание |
Managing Whitespace and new line character
" \tWhitespace at beginning and end. \t\n\n".strip
strip both sides
fear = " F " puts fear.strip
Strip from both side in place
fear = " F " p fear.strip!
strip removes other kinds of whitespace, too:
puts "\t\tBye, tabs and line endings!\r\n".strip
Strip the tab and new line characters
"\t\tBye, tabs and line endings!\r\n".strip # => "Bye, tabs and line endings!"