From: Albert Schlef Date: 2008-05-07T04:53:45+09:00 Subject: Re: Escaped characters from the command-line > I'm still looking for a more elegant way then the > heavy case statement. > I've experimented with a gsub! solution but the way backslashes are > escaped in regular expressions (particularly when reinserting into a > string) has me blocked at the moment. All you're looking for is a cool one-liner? Here's one: s.gsub!(/(\\[ntr])/) { eval %/"#$1"/ } It replaces any \n and \t sequence by it's character. You can even enhance the regexp to support \x sequences as well: s.gsub!(/(\\([ntr]|x\d+))/) { eval %/"#$1"/ } -- Posted via http://www.ruby-forum.com/.