Friday, November 13, 2009

How to remove extra spaces in ruby strings

by Sandip Ransing 0 comments

In ruby, one can write multiple codes to remove multiple blank spaces inside strings (sentenses)
 
"Write      your       string            here   ".squeeze.strip
"This     is my      input  string     ".gsub(/ +/, ' ')
"Write      your       string          here   ".split('  ').join(' ')

blog comments powered by Disqus

About The Author

Sandip is a ruby on rails developer based in pune and also a blogger at funonrails. Opensource contributor and working with Josh software Private Limited. for more info read Follow Sandip on Twitter for updates.

Connect With Me...

Github Projects

@sandipransing Twitter