From: Jeremy Bopp Date: 2010-12-14T05:24:48+09:00 Subject: Re: Substituting New Line Character On 12/13/2010 02:14 PM, A. Mcbomb wrote: > Thanks Jeremy. > Everythin looks good if I use
where I need it and then view it with > a browser. The text I'm dealing with is HTML but I'm trying to get rid > of all the HTML tags and get the raw data into a text file on my Red Hat > machine. > > I tried iterating through each line of the HTML text and using: > > j.gsub!("substituton for where I want the new line", "carriage > return") > > For "carriage return", I have tried using \r and \n but it puts those in > literally and does not force a carriage return when I open up the file > in VI. > > It seems like \n and \r are not working in this case. They do work actually: irb(main):001:0> a = "hello world" => "hello world" irb(main):002:0> a.gsub!(" ", "\n") => "hello\nworld" irb(main):003:0> puts a hello world => nil As you can see, the string gets the newline character inserted in place of the space character in this example. Can you reproduce this problem with a trivial example? I suspect that if you try that you might find the problem. What's going wrong is not readily apparent to me with the information available. -Jeremy