in reply to Regular expression parse pathname

Just a little comment about the original regex. There's no need to escape special characters inside a character class match = character matches inside square brackets. Even no need to escape a forward slash inside square brackets, as regex engines know they're inside a character class and won't confuse with a regex delimiter (normally forward slash.) So if the regex was originally intended for unix only paths, no need for the backslash..unless you also want to catch dos style path delimiter.
the hardest line to type correctly is: stty erase ^H