From: Robert Klemme Date: 2012-07-22T00:12:08+09:00 Subject: Re: How to replace plain strings? On Thu, Jul 19, 2012 at 8:03 PM, Albert Schlef wrote: > I finally solved my problem by doing: > > "a b c".sub("b") { "believe\\+me" } > > But I wonder if this is the "best" Ruby has to offer for my very humble > demands. It's usually slower. The intended use of the block form is where calculations need to be done for each replacement. That's not the case here. Please see Brian's excellent explanation of how it's done without block and why so many backslashes are needed. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/