Regular expression for validating filename

any string that doesn't contain a slash is a valid filename.There are also a small number of reserved file names that cannot be created, such as "CON", "PRN", "CLOCK$" and "LPT1" -- these special filenames were used to represent various hardware devices in DOS. any string that doesn't contain a slash is a valid filename.Hi, Im looking for a regular expression to check that a entered filename is valid.

orange tree nottingham speed dating - Regular expression for validating filename

Unfortuntely regular expression syntax is a very foriegn langauge to me. any string that doesn't contain a slash is a valid filename.

(Because of course, the slash must be a directory separator.) Any other character is valid in a file name -- asterisks, question marks, colons, tabs, line feeds, whatever.

-- Toby A Inkster BSc (Hons) ARCS [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux] [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 12 days, .] Sharing Music with Apple i Tunes Good question.

As far as I know, for Linux and most UNIXy OSes it's this: #[^/]# i.e.

Names "." and ".." are technically allowed, but they always already exist. Linux supports dozens of different filesystems and some of those will limit you further. As well as slashes, it doesn't allow colons, backslashes, asterisks, question marks, whitespace other than the space character itself, less-than and greater-than signs, double quotes and the pipe symbol.

Comments