On Mon, Aug 26, 2013 at 1:12 PM, Love U Ruby <lists@ruby-forum.com> wrote:
> In my case the hash is inside the string,but I want the hash back from
> the string? :( I don't know how to do this...
If you must use that format --
2.0.0-p247 :017 > str
=> "1=2,3=(4=5,6=7)"
2.0.0-p247 :018 > eval str.tr('()','{}').gsub(/=/,'=>').prepend('{').concat('}')
=> {1=>2, 3=>{4=>5, 6=>7}}
2.0.0-p247 :019 >
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yCmMq8D-FDgn3asD4ADDbZL3mSh-cxKWP_55V7D781dOg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment