Trim blank newlines from string in Ruby -


I have a string of four empty rows, which make up eight lines in the following:

  str = "aaa \ n \ n \ nbbb \ n \ nccc \ ddd \ n"  

I want to return it all in one line, the output should be on the same line :

  aabbcdd  

I used different trim function to get the output but I still failed.

Which method do I have here?

Ruby (and slightly lesser Pearl-way):

  New_str = str.delete "\ n"  

... or if you want to in-place it:

  str.delete! "\ N"  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -