From: matz@... (Yukihiro Matsumoto) Date: 2002-07-13T17:55:53+09:00 Subject: Re: gsub() replacement containing replaced text Hi, In message "gsub() replacement containing replaced text" on 02/07/13, Harry Ohlsen 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.