Do not modify last path when using replace