A more efficient alternative fix for #1721

I also added a test for cleaning a project with a spliced target path. We can enhance it for more edge cases if warranted. The profile activation to clean one of my projects (with some 30 defined profiles) was really slowing me down.

This approach uses a regex, so now we have two (more) problems. ;)