From: Alex McHale Date: 2004-05-25T00:46:54+09:00 Subject: Re: separate a HTML-tag in a hash Ok this is really rough around the edges and I'm sure has a bug hiding in it, but on your sample there it works fine. It also works for single tags (like checked and last in my example below). This is a Q&D 2 minute job, I'm sure you or someone else can refine it. #!/usr/local/bin/ruby def explode_tag tag return nil unless tag.is_a? String hash = Hash.new unless tag.sub!(/<([^\s]+) /, '').nil? hash['tagName'] = $1 hash[$1] = $2 until tag.sub!(/([^\s]+)\s*=\s*"([^"]*)"\s*/, '').nil? hash[$1] = true until tag.sub!(/([^\s\/<>]+)(\s+|\/|>)/, '').nil? end hash end s = '' h = explode_tag(s) puts h.inspect Also don't be afraid to tell him this is crap! =) Alex McHale