Displaying page
of
pages;
Items to
Title |
Test
Details
Windows Drive Letter & UNC Path
|
Expression |
^((\\\\[a-zA-Z0-9-]+\\[a-zA-Z0-9`~!@#$%^&(){}'._-]+([ ]+[a-zA-Z0-9`~!@#$%^&(){}'._-]+)*)|([a-zA-Z]:))(\\[^ \\/:*?""<>|]+([ ]+[^ \\/:*?""<>|]+)*)*\\?$
|
Description |
This expression was written for C#, and as such you should just be able to drop it in.
It matches Windows paths, be they the drive letter version or the UNC version. It was not written to specifically match filenames, but it will in most cases anyway.
Be aware that Windows has a maximum path+filename length (260 chars on XP) and this regular expression does not check for this.
This has been tested against large datasets.
|
Matches |
C:\Program Files\Test, \\server\share\directory
|
Non-Matches |
c:?Program Files\Lab, \\$erver\sh*re\directory, a:\di:::r
|
Author |
Rating:
Tristan DF Wilson
|
Title |
Test
Details
Windows Filename
|
Expression |
^[^ \\/:*?""<>|]+([ ]+[^ \\/:*?""<>|]+)*$
|
Description |
This was written for C# and so you should just be able to drop it into your C# program.
Although you can create files with leading and trailing spaces through non-GUI means, the Windows GUI itself eats those spaces if you try to rename the file. For this reason I made the decision to consider file names with leading and trailing spaces invalid.
This has been tested against large data sets.
|
Matches |
bla, file.txt, !@#$
|
Non-Matches |
bla , file:txt, /\*?
|
Author |
Rating:
Not yet rated.
Tristan DF Wilson
|
Displaying page
of
pages;
Items to