From: Daniel Finnie Date: 2007-03-11T11:38:22+09:00 Subject: Re: parse hex ascii You could do it like this: "0164".scan(/../).collect {|x| x.hex} Dan Mark Zvilius wrote: > I want to parse a hex-ascii string into an array of numbers. For > example: > > "0164" => [1,100] > > Essentially I need to iterate through character pairs and use > String#hex: > > "01".hex => 1 > "64".hex => 100 > > I can do this easily enough in "C style" with an index into the string, > i.e. equivalent to a C "for" loop. But I'm interested in solutions that > are more in the "Ruby style," using an iterator. > > Suggestions? >