From: Robert Klemme Date: 2005-01-25T17:25:51+09:00 Subject: Re: String.str_replace ???? "E S" schrieb im Newsbeitrag news:20050125052315.WKZL2811.fep31-app.kolumbus.fi@mta.imail.kolumbus.fi... > B) You can use Enumerable: > > class String > def str_replace(what, with) > s = self.collect do |c| > with if c === what > end > end > end I don't think this will work as String#each does not yield single characaters but "lines". >> a=< "foo\nbar\nend\n" >> a.each {|x| p x} "foo\n" "bar\n" "end\n" => "foo\nbar\nend\n" >> a.collect {|x| p x; :x} "foo\n" "bar\n" "end\n" => [:x, :x, :x] Regards robert