From: "Iñaki Baz Castillo" Date: 2009-02-21T01:36:53+09:00 Subject: Re: Un-escaping hexadecimal code El Viernes, 20 de Febrero de 2009, Jeff Schwab escribió: > Iñaki Baz Castillo wrote: > > string = "%61lice" > > string = eval %{ "#{ string.gsub(/%/,'\x') }" } > > => "alice" > > > > How could I avoid the usage of "eval" to un-escape the string? > > s.gsub! /%(\d+)/ do |match| > $1.to_i(16).chr > end > puts s > > You might also consider supporting escaped % literals. Also, it should consider not just number but A-F -- Iñaki Baz Castillo