Title |
Test
Find
Pattern Title
|
Expression |
^[^\\\./:\*\?\"<>\|]{1}[^\\/:\*\?\"<>\|]{0,254}$ |
Description |
Validates a long filename using Windows' rules. Requires one valid filename character other than "." for the first character and then any number of valid filename characters up to a total length of 255 characters. Unresolved is how to prevent the last character from being a "." while still meeting all the features that this regex does now. |
Matches |
abcd.jpg | a b239.abcd ef12983 298 | a....23498 |
Non-Matches |
.abcde.jpg | abcde?.jpg | c:\abcde.jpg |
Author |
Rating:
Not yet rated.
Dale Preston
|
Source |
|
Your Rating |
|
Title: Unicode Support
Name: Dugald
Date: 5/15/2008 2:31:16 AM
Comment:
It would seem abcÑdef is a valid Windows filename, but does not match the regular expression above. The middle character here is from ISO/IEC 8859-1 (00D1/209).
Title: Add extension
Name: Cloink
Date: 11/6/2006 9:37:01 AM
Comment:
Just reduce the max size by a few and demand a suffix/extension:
\.[a-z]{1,5}
Who saves filenames that long?!
Title: Ignores valid names
Name: Thomas
Date: 5/25/2005 5:05:49 AM
Comment:
Names starting with a period (e.g. .htaccess, .jpi_cache) are valid names under Windows. Although explorer won't let you rename a file to start with a period, other programs can save them as such, and you can manipulate the files without any problem.
Title: Allows invalid names
Name: Kris
Date: 3/14/2005 8:25:47 PM
Comment:
Allows input that begins with leading or trailing spaces which are not valid windows filenames. Also allows the input to trail with period which is also invalid.