From: Bertram Scharpf Date: 2009-01-20T13:03:36+09:00 Subject: Re: Gsub!("\n","\n") Hi, Am Dienstag, 20. Jan 2009, 09:19:02 +0900 schrieb Simon Tan: > Hi all, I'm not sure why but I assumed gsub! would allow me to replace > \n with line feeds or \r for carriage returns. str.gsub! "\\n", "\n" str.gsub! "\\r", "\r" This is a security risk: eval %Q("#{str}") Maybe this does: str = "hello\\nbye" str.gsub! /\\(\w)/ do |m| eval '"\\' + $1 + '"' end Okay, \ escaping is a weird matter. You know that gsub! returns nil in case nothing was changed? Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de