From: Ryan Pavlik Date: 2003-06-25T17:49:28+09:00 Subject: Re: another problem with regular expression On Wed, 25 Jun 2003 15:52:07 +0900 "Pe�a, Botp" wrote: > > The second way is probably more efficient, since it can > > optimize the match and do it in one pass. > > not sure if that would scale up to a 10000 entry array though.. This is a good point... it wouldn't. OTOH, it depends on the problem; the first way would likely be poor for a few words on many megs of text; the second would be worse in the way you mentioned. The first is probably the best for the general case, since even though it would be poor for huge amounts of text, it would eventually get done. Of course, you could opt for a hybrid solution (experiment with COUNT for best results): COUNT = 20 i = 0; loop { re = array[i...i+COUNT].join('|') s.gsub(re, '*') i += COUNT break if(i >= array.size) } ;-) -- Ryan Pavlik "I sure as hell didn't learn anything, if thats what you mean." - 8BT