Support all forms of tilde expansion

The previous regex did not correctly identify all forms of possible tilde expansion.  http://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html

Particularly the form `~fred/foo` would not have matched.
I added a test case as well as fixed the regex.