From: Peter Date: 2003-12-17T05:07:04+09:00 Subject: Re: substituting apostrphe's > I have a bit of a problem, I can't seem to substitute an apostrphe > successfully > > a = "'" > a.gsub!(/'/,'\\\'') > puts a > > gives me nothing. > > two backslash gives me syntax error. > > one backslash gives me just the apostrophy. > > How do I do this? irb(main):003:0> a = "a" => "a" irb(main):004:0> a.gsub(/a/, '\'') => "'" irb(main):007:0> a = "abc" => "abc" irb(main):008:0> a.gsub(/a/, '\\\'') so \' gives you the apostrophe, \\\' gives you the part of the string after the match. So three slashes gives nothing because the part of the string after the match is empty. One slash gives you just the apostrophe because you substitute the apostrophe with a brand new one. But I can't say from your code what you want it to do. Peter