From: Jeff Schwab Date: 2009-02-21T02:24:42+09:00 Subject: Re: Un-escaping hexadecimal code I単aki Baz Castillo wrote: > 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 Right you are.