From: Eric Sunshine Date: 2004-02-21T04:42:55+09:00 Subject: Re: [ruby] String#hex confusion On Sat, 21 Feb 2004 04:31:07 +0900, Steven Jenkins wrote: > x(main):008:0> '22'.sub(/(\d\d)/, "#{'\1'.hex.to_s}") > => "0" > I understand everything but the last line. What am I missing? You are applying 'hex' to the literal string "\1". Since '\' is not a hex digit, it returns 0. What you really want is: '22'.sub(/(\d\d)/) { "#{$1.hex.to_s}" } -- ES