Wednesday, 25 November 2015

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”
2.2.2 :019 > a.delete("")
 => "Miasa Pride" 
2.2.2 :020 > a.delete(" ")
 => "MiasaPride" 
2.2.2 :021 > 
Cheers….!!!!!!!!

No comments:

Post a Comment