From: John Date: 2006-04-27T17:56:37+09:00 Subject: I have some problem with convert to symbol, in Hash object I use it functionality: >> Hash[*str.scan(/store\[([^\s,]+)\s*\]=\s*([^,]+)/).flatten] => {"fax"=>"80233923293", "name"=>"Ilyas store", "description"=>"lkjklsdaj", "phone"=>"4999-233-2923"} The problem with covert string to symbol. I want to convert "name" to :symbol "name"=>"Ilyas store" ---> :name => "Ilyas store" ------------------------------------------------------------------------ On Apr 26, 2006, at 7:12 AM, Jonh wrote: > > if params[:param] > paramater = Hash.new > for value in params[:param].split(/,/) > if value =~ /(.*)=(.*)/ > parameter[$1] = $2 > end > end > end > puts parameter.inspect Does this help? >> str = "store[name]=Ilyas store,store[phone]= 4999-233-2923, store [fax]= 80233923293,store[description]=lkjklsdaj,save=save,cancel=cancel" => "store[name]=Ilyas store,store[phone]= 4999-233-2923, store[fax]= 80233923293,store[description]=lkjklsdaj,save=save,cancel=cancel" >> Hash[*str.scan(/([^\s,]+)\s*=\s*([^,]+)/).flatten] => {"cancel"=>"cancel", "store[fax]"=>"80233923293", "store [name]"=>"Ilyas store", "save"=>"save", "store [description]"=>"lkjklsdaj", "store[phone]"=>"4999-233-2923"} James Edward Gray II -- Posted via http://www.ruby-forum.com/.