On Thu, Dec 2, 2010 at 6:27 PM, Jester Mania <jester_b84 / hotmail.com> wrote: > Basically, the text file contains lines in the following format (where > \n is not really a newline but the text "\n"): > > TextString [SYMBOL]\nDefinition > > I need to replace the text \n with a tab, as I am attempting to separate > all the "tokens" by tabs. The issue here is that \n happens to be a > newline character. I tried searching the forums and tried the following > code: > > lineItem = line.gsub("\\\\n", "\t") This may be useful: $ irb >> s = 'car\nplane\ntrain \n boat' # because of ' the \n is not interpreted as newline => "car\\nplane\\ntrain \\n boat" >> s.gsub(/\\n/, "\t") # here the \\n is really '\n' , but "\t" is really <TAB> => "car\tplane\ttrain \t boat" >> # the result has <TAB>s now Peter