From: 7stud -- Date: 2011-04-26T06:27:19+09:00 Subject: Re: How to split dot “.” only before equal “=” Sira PS wrote in post #994664: > 7stud, > > actually i need to split dot before equal sign except after equal sign > > the values i need are > > Project > risksPotentialAfterSum > Pot. aft. > > can i split it the get these result in the same time? That isn't necessary: str = 'projects.risks.Index.flash_downloading=Downloading.test' key_str, val = str.split('=') keys = key_str.split(/[.]/) temp = master = {} last = keys.last keys.each do |key| if key == last temp[key] = val else temp = temp[key] = {} end end p master --output:-- {"projects"=>{"risks"=>{"Index"=>{"flash_downloading"=>"Downloading.test"}}}} -- Posted via http://www.ruby-forum.com/.