From: John Pritchard-williams Date: 2008-09-02T18:33:51+09:00 Subject: Re: escaping ' David Nguyen wrote: > Hi, > I need to replace ' by \'. How can I do that? > > Thanks This was harder than I thought...in "vi"(vim actually) I just had to: 1,$ s/'/\\'/g But Ruby didn't seem to like that.... Anyway, for reasons unknown to me, this works: puts "'hello'".gsub("'","\\\\'") Cheers John -- Posted via http://www.ruby-forum.com/.