From: Ronald Fischer Date: 2007-09-10T20:55:25+09:00 Subject: gsub! and quoting question I thought this would be a trivial task, but it seems to be more difficult than expected: I have a variable, data, containing some string. I would like to preprend every single apostrophe in this string by a backslash. Here is my solution: data.gsub!(/'/,%q(\\')) Strangely, this does not work. I tested it with data containing a string consisting of a single quote solely, and surrounded the code by "puts" like this: data=%q(') puts ":"+data+" replace quotes by "+%q(\\') data.gsub!(/'/,%q(\\')) puts "data length now #{data.length}" This produced as output: :' replace quotes by \' data length now 0 From this I conclude that the gsub! had shortened the string to length zero. Any explanation for this? How do I solve my problem in a proper way? Ronald -- Ronald Fischer Phone: +49-89-452133-162