From: Jani Soila Date: 2006-07-22T02:04:28+09:00 Subject: Replacing ' with \' using gsub I tried to replace "'" characters with "\'" strings using gsub. What happened instead was something completely different. Am I missing something here? (in irb) irb(main):001:0> s = "a'b'" => "a'b'" Unexpected result irb(main):002:0> s.gsub(/'/, "\\'") => "ab'b" Also with this irb(main):003:0> s.gsub(/'/, '\\\'') => "ab'b" However this works irb(main):004:0> s.gsub(/'/, "\\x'") => "a\\x'b\\x'" Thank you for your help! -js -- Posted via http://www.ruby-forum.com/.