From: Paul Mena Date: 2012-12-21T05:36:05+09:00 Subject: trying to strip characters from a line I'm reading a table from a MySQL database and then processing it row by row, stripping each line of certain characters ([, ], " and comma) before writing it to a file. The code is running without errors, but it's not stripping any of the characters as I would expect. Here's the code: #!/usr/bin/ruby require 'mysql' @bad_chars = '[],"' begin con = Mysql.new 'localhost', 'root', 'menagerie', 'haiku_archive' rs = con.query("SELECT * FROM archive_2012") n_rows = rs.num_rows n_rows.times do begin file = File.open("archive.html", "a") line = rs.fetch_row.to_s line.gsub(/\[\]\,\"/,'') file.write(line) file.puts "
" end end end Executing the code results in an "archive.html" file with all of the "stripped" characters still intact. Am I invoking the gsub method incorrectly? Thanks in advance for any help. -- Posted via http://www.ruby-forum.com/.