From: Kyle Schmitt Date: 2008-05-02T01:54:33+09:00 Subject: Re: splitting with a regex & keeping a ref? Robbert, yermej, David, Thanks a bunch! Here's what I finally came up with, in case anyone's bored enough to wonder. file="/path/to/smb/file/sample.conf" regex=/(\[[a-z0-9]+\])([^\[]*)/i samba_config={} File.open(file){|f| f.read()}.scan(regex) do |title,options| samba_config.store(title,{}) options.strip.each() do |l| samba_config[title].store(l[/^[^=]*/].strip,l[/[^=]*[^\n]$/].strip) end end