From: nobu.nokada@... Date: 2002-04-26T23:08:47+09:00 Subject: Re: expand_path and overlap Hi, At Fri, 26 Apr 2002 22:42:03 +0900, Morris, Chris wrote: > > I find this an interesting puzzle. Question: what would this return: > > > > collapse_path("b/c/f", "/a/b/c/d/e/b/c/g/h") > > #^^^^^^^^^^^^ or whatever :-) > > At the moment, I'm thinking it should be: > > /a/b/c/d/e/b/c/f > > (which could probably be gathered from my other recent post :) I'm not sure, is this like what you want? def collapse_path(path, base) head, = path.split("/", 2) base.rindex(%r"(\A|.*/)#{Regexp.quote(head)}(?:/|\z)") ($1 or base) + path end -- Nobu Nakada