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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find File Path
Expression
^(([a-zA-Z]\:)|(\\))(\\{1}|((\\{1})[^\\]([^/:*?<>"|]*))+)$
Description
Checks for a valid Filepath, either located on a local drive or a UNC share on the network. Use the following string to include the regex within a XML defintion file: RegEx="^([a-zA-Z]\:)|(\\)(\\{1}|((\\{1})[^\\]([^/:*?&lt;&gt;&quot;|]*(?&lt;!\[\])))+)$"/> (encode the appropiate HTML characters like <,>," with the appropiate HTML codes < = (ampersand)lt; > = (ampersand)gt; " = (ampersand)quote;
Matches
C:\SomeFilePatt|\\SomeServer\SomeShare
Non-Matches
C:|\SomeServer
Author Rating: The rating for this expression. Jens K. Suessmeyer
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: thanks
Name: Ilham Israfilov
Date: 4/11/2014 5:02:04 AM
Comment:
big big big thanks!!! works perfect. i can validate both local and network paths


Title: thanks
Name: Ilham Israfilov
Date: 4/11/2014 5:01:50 AM
Comment:
big big big thanks!!! works perfect. i can validate both local and network paths


Title: thanks
Name: Ilham Israfilov
Date: 4/11/2014 5:01:36 AM
Comment:
big big big thanks!!! works perfect. i can validate both local and network paths


Title: Thanks for your regEx
Name: Vasiliy
Date: 10/3/2009 5:14:44 AM
Comment:
It's all good, but I found some trouble: C:\*folder\ is match by your regEx. I corret your regEx to this: ^(([a-zA-Z]\:)|\\)(\\|(\\[^/:*?<>"|]*)+)$


Title: Big Thanks!!!
Name: Yuriy
Date: 3/10/2009 5:59:39 PM
Comment:
Helped me big time solve my problem with FileUpload control (http://www.galanter.net/?p=128). Job well done!


Title: Simple and Sweet Expression
Name: Nayan
Date: 10/17/2008 12:48:29 AM
Comment:
Tried many expressions but this one was the only one worked C:\ \\test\c$\ \\123.2.2.2\c$\ C:\test C:\test\myfile.txt


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