Hi Brett. I don't have Ruby installed, so I came up with a version that used `sed` instead. Here's a breakdown of what the function does:
* Strips white spaces from the input parameter.
* Converts input parameter to have [^/]* after every character.
* Uses the resulting pattern to find a match between two /'s (while also prefixing the pattern with [^/]*).
* If a match is found, return everything up to the end of the match, stripping off any trailing test.
function _up()
{
local rx
rx=$(echo "$1" | sed -e "s/\s\+//g" -e "s/\(.\)/\1[^\/]*/g")
echo -n $(pwd | sed -e "s/\(.*\/[^\/]*${rx}\)\/.*/\1/")
}