From: Eric Armstrong Date: 2006-07-29T08:51:57+09:00 Subject: Re: Finding "\" in a string Logan Capaldo wrote: > > when I need to gsub backslashes I use a block: > > gsub(%r{\}) { '\\' } > That's odd. I would have expected that to work, since the value of the block is the value of the string. But %r{\} produces: "unterminated string meets end of file" And { '\\' } inserts a single backslash. Paul's version worked: gsub("\\"){ "\\\\" } As did this: gsub(%r{\\}) { '\\\\' } Thanks for all the choices! I'm picking the version with the simplest syntax I'm likely to recall: gsub("\\") { '\\\\' } It may be slower, but it's readable. Thanks again, guys. There is no way on earth I would found the solution. Heck, even now that I see it, I don't really understand it. (I'm hoping that Paul's in-depth explanation will make more sense after I've read it 5 or 6 times.) :_)