From: ts Date: 2002-04-27T01:40:08+09:00 Subject: Re: expand_path and overlap >>>>> "M" == Morris, Chris writes: M> assert_equal("/a/b", collapse_path_ts("/a/b", "/")) M> assert_equal("/m/n", collapse_path_ts("/m/n", "/a/b")) Well, def collapse_path_ts(p, m) if %r{^([^\0]*/)([^\0]+)(?:/|\z)[^\0]*\0\2(.*)} =~ m + "\0" + p $1+ $2 + $3 else if p[0] == ?/ p else m + "/" + p end end end p.s.: but verify it :-) Guy Decoux