From: Max Muermann Date: 2006-12-06T19:01:28+09:00 Subject: Re: GOLF: hex string to dotted quad On 12/6/06, Martin DeMello wrote: > irb(main):021:0> hex_ip = "c0a80167" > => "c0a80167" > irb(main):022:0> ip = hex_ip.scan(/../).map {|i| i.to_i(16)}.join(".") > => "192.168.1.103" hex_ip.gsub(/../) {|s| "#{s.hex}."}[0..-2] The deletion of the trailing '.' is so ugly... but it's a leetle bit shorter ;) Cheers, Max