From: Martin DeMello Date: 2003-05-30T20:48:04+09:00 Subject: Re: substitution weirdness Ian Macdonald wrote: > > I'm trying to replace every instance of ' with \' but it's proving very > tricky. Nothing I can come up with seems to work, no matter how many > backslashes I use, whether I use single or double quotes, whether or not > I use gsub with a block, etc. > > This should be so easy, but it has me stumped. foo = "'123" puts foo.gsub(/'/) {'\\'+"'"} I find it more readable than the multiply-self-escaping string of backslashes. martin