⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 10 - managing whitespace.rb

📁 O Reilly Ruby Cookbook source code
💻 RB
字号:
" \tWhitespace at beginning and end. \t\n\n".strip# => "Whitespace at beginning and end."#---s = "Some text."s.center(15)                    # => "  Some text.   "s.ljust(15)                     # => "Some text.     "s.rjust(15)                     # => "     Some text."#---#Normalize Ruby source code by replacing tabs with spacesruby_ode.gsub("\t", "  ")#Transform Windows-style newlines to Unix-style newlines"Line one\n\rLine two\n\r".gsub("\n\r", "\n")# => "Line one\nLine two\n"#Transform all runs of whitespace into a single space character"\n\rThis string\t\t\tuses\n all\tsorts\nof whitespace.".gsub(/\s+/, " ")# => " This string uses all sorts of whitespace."#---" \bIt's whitespace, Jim,\vbut not as we know it.\n".gsub(/[\s\b\v]+/, " ")# => " It's whitespace, Jim, but not as we know it. "#---s = "   Whitespace madness! "s.lstrip                              # => "Whitespace madness! "s.rstrip                              # => "   Whitespace madness!"#---"four".center(5)                      # => "four ""four".center(6)                      # => " four "#---

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -