It took a while of playing around, but this works: resp = Base64.decode64(elem.text) re = /((?:[\w-]+)\s*=\s*(?:(?:"[^"]+")|(?:[^,]+)))/ response = {} resp.scan(re) do |kv| k, v = kv[0].split('=', 2) v.gsub!(/^"(.*)"$/, '\1') response[k] = v end And isn't totally repulsive. Thanks.