From: Stefan Rusterholz Date: 2007-08-07T00:13:04+09:00 Subject: Re: Determining the common prefix for several strings Todd Burch wrote: > I have several strings to analyze. The strings are the names of a list > of things that were once ordered and now are not. A typical array of > names might look like this: > > item001 > item004 > item002 > item002b > item002C > item 5 > item 10 > itemize this > > I want to parse these names and determine that "item" is the common > prefix. > > I know how to armstrong my way through it a character at a time, but I'm > thinking that Ruby probably has a very elegant way of doing this that > I'm not familiar with yet. > > Thanks, Todd Wow, I'm surprised nobody had the idea of simply using Array#abbrev, which is included in the stdlib. Regards Stefan -- Posted via http://www.ruby-forum.com/.