Robert Klemme <bob.news / gmx.net> wrote:
> Better scaling for large arrays:
> 
> string.gsub( /\b(\w+)\b/ ) {|m| array.include?( m ) ? "*" * m.length : m }
> 
> One can optimize performance by changing the array into a hash and testing
> for hash.has_key? instead of array.include?

Or something like

hash = {}
array.each {|e| h[e] = '*' * e.length}
string.split(/\b/).map {|w| hash[w] || w}.join()

martin