From: Kent Sibilev Date: 2005-06-29T23:12:13+09:00 Subject: Re: regex and gsub quest gsub is not a destructive method, meaning every time you call it it returns a new string. You should use gsub! mehtod which makes changes in place. Kent. On 6/29/05, Charles L. Snyder wrote: > Hi > > Another quick question (at the risk of being the person who asks for help on > adding 2+2 at the alt.math.relatavistic.astrophysics group): > > I am trying to search thru a file (arrays of words and sentence fragments), > and replace the commas with a space. > Why doesn't the code below work : (other than an incorrect regex for comma) > > a = ["hi,there", "jot this note down", "may i,use the, car"] > a.each do |x| x.gsub(/\,/ , " ") end > > - the general method of > array.each do {|e| e.gsub(pattern, replacement)} doesn't work? > > Thanks again > > CLS > > > >