>>829
String#gsub(pattern, replace) は使っちゃダメ。絶対。
String#gsub(pattern) {|matched| .... } の方を使いましょう。

puts "aa'aa'aa".gsub(/\'/) { "\\'" }