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

推薦閱讀
- Learning PostgreSQL
- Apache Spark 2.x Machine Learning Cookbook
- 精通Scrapy網(wǎng)絡(luò)爬蟲
- Apex Design Patterns
- Windows Forensics Cookbook
- Modern JavaScript Applications
- Swift細(xì)致入門與最佳實(shí)踐
- NGINX Cookbook
- Mastering Linux Security and Hardening
- Android系統(tǒng)下Java編程詳解
- Java EE Web應(yīng)用開發(fā)基礎(chǔ)
- HTML5移動(dòng)Web開發(fā)
- Applied Deep Learning with Python
- MySQL數(shù)據(jù)庫應(yīng)用實(shí)戰(zhàn)教程(慕課版)
- Developing Java Applications with Spring and Spring Boot