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

推薦閱讀
- 信息可視化的藝術(shù):信息可視化在英國
- 深入實(shí)踐Spring Boot
- Visual Basic程序設(shè)計(jì)(第3版):學(xué)習(xí)指導(dǎo)與練習(xí)
- C語言程序設(shè)計(jì)教程(第2版)
- Java開發(fā)入行真功夫
- 征服RIA
- PLC編程及應(yīng)用實(shí)戰(zhàn)
- Android 應(yīng)用案例開發(fā)大全(第3版)
- JavaScript動(dòng)態(tài)網(wǎng)頁開發(fā)詳解
- Scala謎題
- 深入淺出Serverless:技術(shù)原理與應(yīng)用實(shí)踐
- 量化金融R語言高級(jí)教程
- Java編程的邏輯
- 蘋果的產(chǎn)品設(shè)計(jì)之道:創(chuàng)建優(yōu)秀產(chǎn)品、服務(wù)和用戶體驗(yàn)的七個(gè)原則
- 一塊面包板玩轉(zhuǎn)Arduino編程