Singeo wrote:
> Hi, I'm pretty new to Ruby. I've got a text file where I need to
> remove some new line characters. I've tried everything I can think of
> to do this with no success, including:
> 
> line.gsub!("/r","")
> line.gsub!("/n","")
> line=line.chomp

In case your problem is just your Ruby syntax:

1. Replace the forward slashes (like in "/r") by
backward slashes ("\r" in your above mentioned
solution.

2. Make the first parameter to the gsub! method
a Regexp instead of a string. The API docs say:
"... if it is a String then no regular expression
metacharacters will be interpreted ...".

This is why neither "/r" (1) nor "\r" (2) will
work.



If chomp does not work, you may be using a Mac
file under Linux or Windows. In that case you may
want to try something like

line.gsub!(/\015/, '')


Hermann