Skip to content

Instantly share code, notes, and snippets.

@stevenschobert
Last active August 29, 2015 13:58
Show Gist options
  • Save stevenschobert/10023051 to your computer and use it in GitHub Desktop.
Save stevenschobert/10023051 to your computer and use it in GitHub Desktop.
My take on a filepath testing regular experession. Requires a relative or absolute path, and an extension. Excludes plain filenames.
^[\.+]*\/+.*\.[a-zA-Z0-9]+$
# Matches
/Users/stevenschobert/Documents/project/tmp/tmp-8205.txt
../somepath.txt
./sompat/h.d
./Something with spaces/word.txt
# Does not match
../sompath
something.txt
some other /word.txt
.some other /word.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment