Mage wrote:
> Michael Morin wrote:
>>     map {|s|
>>
> It won't work if any if the values has a comma, like str = ' "gaz" =>
> "1", "lift" =>"white, small"'
> 
> split(/, +/) will break "white, small"
> 
> A much more complicated regexp should work. As far as I see I will stay
> with eval.
> 
>        Mage

s = str.match(/^\s*\{\s*(.+)\}\s*$/).captures.first; 
Hash[*s.scan(/\"([^"]*)\"\s*=>\s*\"([^"]*)\"/).flatten]

Lets assume that each hash is in form:
{ "something" => "someting elswe"[, *] }

Escaped " in strings are not supported here.
-- 
Posted via http://www.ruby-forum.com/.