Trim white spaces from ruby string


Let’s play with ruby function to remove all white spaces.
1.9.3p125 :001 > a = “Miasa Pride”
 => “Miasa Pride”
1.9.3p125 :002 > a.strip
 => “Miasa Pride”
1.9.3p125 :006 > a.gsub(/\s+/, “”)
 => “MiasaPride”
1.9.3p125 :007 > b = ” Miasa Pride “
 => ” Miasa Pride “
1.9.3p125 :008 > b.gsub(/\s+/, “”)
 => “MiasaPride”
1.9.3p125 :009 > c = ” Miasa@Pride “
 => ” Miasa@Pride “
1.9.3p125 :010 > c.gsub(/\s+/, “”)
 => “Miasa@Pride”
Cheers….!!!!!!!!

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s