Title |
Test
Find
Full Windows Folder Drive Path
|
Expression |
^[A-Za-z]:\\([^"*/:?|<>\\.\x00-\x20]([^"*/:?|<>\\\x00-\x1F]*[^"*/:?|<>\\.\x00-\x20])?\\)*$ |
Description |
Validates the format of a Windows folder path ending with a backslash using the drive path--without using lookaround.<br><br>Windows folder drive path components: <br>(I) The drive can only be one letter. <br>(II) The folder and subfolder names (without the drive) (1) Can contain any character except ones with an ASCII code in the range of 0 (x00) through 31 (x1F) and the following: " * / : ? | < > \ (Reference: http://msdn2.microsoft.com/en-us/library/aa365247.aspx) (2) Cannot begin or end with a space or period. |
Matches |
d:\, E:\reference\h101\ |
Non-Matches |
j:ohn\, \\Dpk\, G:\GD, \\cae\.. ..\, \\be\projects$\Wield\Rff\, \\Dpk\T c\ |
Author |
Rating:
Not yet rated.
John Marshall
|
Source |
|
Your Rating |
|
Title: Paths only, great
Name: Tom Derks
Date: 6/5/2014 6:30:56 AM
Comment:
I was playing with an regex to check if a user entered a correct filepath. This path is needed by a python script to prepare archived documents. My old regex accepted some silly mistakes like c:\\. As i could not find the flaw i searched for a better one. But most regular expressions i found where to check a complete path inclusive the files. This regex checks only the folder path and is exactly what i need.