Michael Morin wrote:
> You could do something like this:
>
> #!/usr/bin/env ruby
> # UziMonkey <uzimonkey / gmail.com>
>
> str = %q{"gaz"=>"1", "viz"=>"1", "lift"=>"0", "kamra"=>"1","klima"=>"0"}
>
> hash = Hash[*
>   str.
>     split(/, +/).
>     map {|s|
>       s.match( /"([^"]+)"=>"([^"]+)"/ )[1,2]
>     }.
>     flatten
> ]
>
> puts hash.inspect
>
> But the regex makes a lot of assumptions.  If the format of the hash 
> changes at all (for example, quotes removed or changed to single 
> quotes), it will break.  If not, it should work fine.
>

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