From: Phrogz Date: 2007-12-15T03:50:02+09:00 Subject: Re: simple way to turn "foo and bar" to "+foo +bar" On Dec 14, 11:22 am, 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. It's elegant, but it assumes that the search phrase always has "and". Although not originally specified either way, that seems like an unlikely assumption. But then, I don't know the problem domain.