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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find 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: The rating for this expression. Tristan DF Wilson
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

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