RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

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
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

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.


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials