📄 03 - reversing a string by words or characters.rb
字号:
s = ".sdrawkcab si gnirts sihT"s.reverse # => "This string is backwards."s # => ".sdrawkcab si gnirts sihT"s.reverse! # => "This string is backwards."s # => "This string is backwards."#---s = "order. wrong the in are words These"s.split(/(\s+)/).reverse!.join('') # => "These words are in the wrong order."s.split(/\b/).reverse!.join('') # => "These words are in the wrong. order"#---"Three little words".split(/\s+/) # => ["Three", "little", "words"]"Three little words".split(/(\s+)/) # => ["Three", " ", "little", " ", "words"]#---
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -