From: Alex Date: 2009-05-27T05:16:53+09:00 Subject: Re: Replace empty or strange characters within array of arrays --001485f1db5e2ba682046ad668af Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Well, to search through your elements and do a replacement, you could do something like this: @rows.each do |x| x.each do |y| y.gsub!(/regex/) {|match| do_your_substitution(match)} end end Or something to that effect, but you know what they say about regular expressions and using them to solve problems. :) Using any combination of the inject/map/each methods and doing substitutions that way may be your best bet, but some of the more experienced rubyists here may have better suggestions. Alex On Tue, May 26, 2009 at 4:07 PM, Joel Dezenzio wrote: > Alex wrote: > > Maybe I'm missing some part of the question, but you can just assign a > > value > > to that element in the array like anything else. > > @rows[120][0] = 120 > > > > > > > > Alex > > thanks Alex, the index started from 0 so it was actually @rows[119][0] = > 120 but that worked. > > I didn't figure on doing the simplest form of a fix for some reason (too > much reading this week). > > I still would like to know what the best way for (find/replace) in an > array would be going forward. Perhaps I'm just not searching in the > right way for the answer. > > I originally tried to use a.each to look for a set condition and then > apply something else. I'm sure I'll find the answer soon enough through > trial and error. Your fix is the simplest and works. > > -- > Posted via http://www.ruby-forum.com/. > > --001485f1db5e2ba682046ad668af--