- Comprehensive Ruby Programming
- Jordan Hudgens
- 86字
- 2021-07-02 21:13:28
Using the strip method
Let's start off by analyzing the strip method. Imagine that the input you get from the user or from the database is poorly formatted and contains white spaces before and after the value. To clean the data up, we can use the strip method. Consider this example:
str = " The quick brown fox jumped over the quick dog "
p str.strip
When you run this code, the output is just the sentence without the white spaces before and after the words:

推薦閱讀
- 玩轉(zhuǎn)Scratch少兒趣味編程
- Building a Quadcopter with Arduino
- Reactive Android Programming
- Instant Ext.NET Application Development
- Keras深度學(xué)習(xí)實戰(zhàn)
- Raspberry Pi Home Automation with Arduino(Second Edition)
- Tableau 10 Bootcamp
- 用案例學(xué)Java Web整合開發(fā)
- Rust游戲開發(fā)實戰(zhàn)
- 細(xì)說Python編程:從入門到科學(xué)計算
- Visual Basic程序設(shè)計習(xí)題與上機實踐
- JavaScript+jQuery網(wǎng)頁特效設(shè)計任務(wù)驅(qū)動教程
- PHP與MySQL權(quán)威指南
- Julia數(shù)據(jù)科學(xué)應(yīng)用
- STM8實戰(zhàn)