- 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:

推薦閱讀
- 基于粒計算模型的圖像處理
- AngularJS Testing Cookbook
- HBase從入門到實戰(zhàn)
- 區(qū)塊鏈:以太坊DApp開發(fā)實戰(zhàn)
- MongoDB權(quán)威指南(第3版)
- 零基礎(chǔ)入門學習Python
- Learning SciPy for Numerical and Scientific Computing(Second Edition)
- The DevOps 2.5 Toolkit
- Python數(shù)據(jù)結(jié)構(gòu)與算法(視頻教學版)
- 計算機應(yīng)用基礎(chǔ)實踐教程
- Elasticsearch Essentials
- ROS機器人編程實戰(zhàn)
- Solr權(quán)威指南(下卷)
- R語言數(shù)據(jù)分析從入門到實戰(zhàn)
- HTML5 and CSS3:Building Responsive Websites