Would it make sense to add this to the Ruby FAQ? On a related note, I have been reading the Programming Ruby book and there is a pretty good section on gotchas that might also be good for the FAQ. Not sure how the authors feel about having the information in both places? Maybe have a link to the PR section from the FAQ? John. "Yukihiro Matsumoto" <matz / ruby-lang.org> wrote in message news:1026541001.000220.29303.nullmailer / picachu.netlab.jp... > Hi, > > In message "gsub() replacement containing replaced text" > on 02/07/13, Harry Ohlsen <harryo / zip.com.au> writes: > > |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. > > "\\'" in a replacement string is substitute by the value of $', so you > have to say > > x.gsub("'", "\\\\'") > > matz. > >