From: ts Date: 2006-07-22T02:30:21+09:00 Subject: Re: Replacing ' with \' using gsub >>>>> "J" == Jani Soila writes: J> irb(main):001:0> s = "a'b'" J> => "a'b'" J> Unexpected result J> irb(main):002:0> s.gsub(/'/, "\\'") J> => "ab'b" "\\'" is the same than $', i.e. MatchData#post_match. For example irb(main):001:0> s = "a'b'" => "a'b'" irb(main):002:0> s.match(/'/).post_match => "b'" irb(main):003:0> ruby replace the first <'> with the second <'> with <> (there is nothing after the last ') Guy Decoux