.I don't know of anything in built but you could implement Suffix
Trees (http://www.dogma.net/markn/articles/suffixt/suffixt.htm) to do
this I would guess.

Farrel

On 5/16/05, Bill Kelly <billk / cts.com> wrote:
> Hi,
> 
> Is there any ruby built-in that might tell me how
> many characters match (are in common) from the start
> (left) of two strings?  E.g.
> 
>  "abcxxxxxx".lcommon("abcdezzzzz")  # => "abc" (or 3)
> 
> All I need is the length but a substring would be
> fine too.
> 
> Figured I'd ask in case I'd overlooked a nicer way
> to do this than writing a loop.  :)
> 
> Thanks,
> 
> Regards,
> 
> Bill
> 
>