From: Harry Ohlsen Date: 2002-07-13T14:07:25+09:00 Subject: gsub() replacement containing replaced text This feels like a terribly newbie question to be asking, but I'm stymied ... I want to replace all single quotes in a string with backslask followed by a single quote. The obvious approach doesn't seem to work, presumably because the replacement contains the pattern that's been replaced. I assume there's an easy way to do this, but can't for the life of me think how. Here's an example of the problem ... irb(main):001:0> x="Don't say goodbye" "Don't say goodbye" irb(main):002:0> x "Don't say goodbye" irb(main):003:0> x.gsub("'", "\\'") "Dont say goodbyet say goodbye" irb(main):004:0>