html_content.scan(/<table.*\/table>/mi).to_s with Ruby 1.9 includes array brackets in the string. Try .join.