From: Gary Watson Date: 2010-09-18T04:28:09+09:00 Subject: Re: search and replace Gary Watson wrote: > John Smith wrote: >> Hi everyone, >> >> I want to be able to run a program that will do a bunch >> of searches specified in an array of strings, and replace the >> first occurrence of those strings with strings specified on a >> second array for a given text file. >> >> What would be the best way to do this? >> >> Ted. > > try > > (["one", "two", "three", "four"].zip ["crazy", "monkeys", "go", "to", > "school"]).collect {|tuple| tuple[0].gsub("o", tuple[1])}. forgot to add, the output is ["crazyne", "twmonkeys", "three", "ftour"] not sure if that's what you wanted, but maybe it'll give you some ideas. -- Posted via http://www.ruby-forum.com/.