From: Ryan Pavlik Date: 2003-06-25T15:42:00+09:00 Subject: Re: another problem with regular expression On Wed, 25 Jun 2003 15:27:06 +0900 "Rob" wrote: > What I am trying to do is that everytime the program finds one of the words > from the list in the text, > it will place an astherisc * to replace that word. > > But I cannot figure out how to do this because it is an array not a regular > expression. Short way: array.each { |w| s.gsub!(w, "*") } Longer, possibly more efficient way: re = array.join('|') s.gsub!(/(#{re})/, "*") The second way is probably more efficient, since it can optimize the match and do it in one pass. HTH, -- Ryan Pavlik "And I'm 10,000 feet up in the air. Dang it." - 8BT