>>>>> "M" == Morris, Chris <chris.morris / snelling.com> writes:

>> collapse_path("b/c/f", "/a/b/c/d/e/b/c/g/h")
>> #^^^^^^^^^^^^ or whatever :-)

M> At the moment, I'm thinking it should be:

M>   /a/b/c/d/e/b/c/f

 Well, try this

   def collapse_path(p, m)
      if %r{^([^\0]*/)([^\0]+)(?:/|\z)[^\0]*\0\2(.*)} =~  m + "\0" + p
         $1+ $2 + $3
      else
         m + "/" + p
      end
   end

 but verify it :-))


Guy Decoux