Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!talisker.lacave.net!lacave.net!not-for-mail From: 7stud -- Newsgroups: comp.lang.ruby Subject: Re: How to split dot “.” only before equal “=” Date: Mon, 25 Apr 2011 16:27:19 -0500 Organization: Service de news de lacave.net Lines: 40 Message-ID: <767901e2edc9e860b36205e0197f978f@ruby-forum.com> References: <18aacfcb7224df848f220e5e5c060ee9@ruby-forum.com> <2bcb1fea255cf99800791245bd83bfac@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1303766880 7838 65.111.164.187 (25 Apr 2011 21:28:00 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Mon, 25 Apr 2011 21:28:00 +0000 (UTC) In-Reply-To: <2bcb1fea255cf99800791245bd83bfac@ruby-forum.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 382166 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <767901e2edc9e860b36205e0197f978f@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3478 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/.