From: "Mauricio Fernández" Date: 2002-08-20T02:29:54+09:00 Subject: Re: Unescaping strings On Mon, Aug 19, 2002 at 03:35:42PM +0900, Joel VanderWerf wrote: > One line, but kind of "evil": > > eval "\"#{s}\"" One line too, but less evil: astring.gsub!(/\\[nt\\\"]/) { |x| eval "\"#{x}\"" } => astring = '[\nA\tB\\\\C\"D]' puts astring, astring.inspect astring.gsub!(/\\[nt\\\"]/) { |x| eval "\"#{x}\"" } puts astring, astring.inspect ==> [\nA\tB\\C\"D] "[\\nA\\tB\\\\C\\\"D]" [ A B\C"D] "[\nA\tB\\C\"D]" -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com 'Ooohh.. "FreeBSD is faster over loopback, when compared to Linux over the wire". Film at 11.' -- Linus Torvalds