From: Eric Promislow Date: 2007-08-04T07:34:59+09:00 Subject: Re: Determining the common prefix for several strings The obligatory solution using zip... # data contains a list of strings aa = data.map{ |x| x.split(//)} bz = aa[0].zip(*(aa[1 .. -1])).map{ |x| x.join("")} target = bz.index( bz.find{ |x| x.squeeze.size != 1}) answer = (target.nil? ? aa[0] : target >= 1 ? aa[0][0 .. target - 1] : []).join("") - Eric