While I applaud your desire to learn regexes and am sure someone will have some suggestions in that regard, I'd recommend for this task that you instead use the
module which is part of core perl and is specifically designed to find paths and filenames in a portable fashion.