From: John Pywtorak Date: 2007-12-15T03:57:02+09:00 Subject: Re: simple way to turn "foo and bar" to "+foo +bar" I could not resist, so a slight mod ;-) "+" << "foo and bar and baz".split(/\s+and\s+/i).join(' +') irb(main):001:0> "+" << "foo and bar and baz".split(/\s+and\s+/i).join(' +') => "+foo +bar +baz" Johnny P MenTaLguY wrote: > On Sat, 15 Dec 2007 03:19:22 +0900, Rolando Abarca wrote: >>> Can anyone help with an elegant solution? >> "foo and bar and baz".split(/\s+and\s+/i).map{|s| "+#{s}"}.join(' ') > > I think this one is best. > > -mental > > >