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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Text Extension
Expression
^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$
Description
This RE validates a path/file of type txt (text file) This RE can be used as a filter on certain file types, while insuring the entire string is a fully qualified path and file. The filter value can be changed or added to as you need
Matches
c:\file.txt | c:\folder\sub folder\file.txt | \\network\folder\file.txt
Non-Matches
C: | C:\file.xls | folder.txt
Author Rating: Not yet rated. Michael Ash
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: <a href="http://www.baidu.com">baidu</a>
Name: <a href="http://www.google.com">google</a>
Date: 9/25/2011 9:22:17 AM
Comment:
WOW, so many spam comments.


Title: Well done
Name: John
Date: 6/27/2011 9:32:17 PM
Comment:
Easy to understand easy to see how to change the extention easy to see what will happen when inplemented love your work.


Title: A little improvement over Mouhcine's version
Name: Razvan
Date: 3/2/2011 7:44:35 AM
Comment:
^(([a-zA-Z]:)|(\\{2}[^\/\\:*?"<>|]+))(\\([^\/\\:*?"<>|]+))*(\\)?$


Title: A little improvement over Mouhcine's version
Name: Razvan
Date: 3/2/2011 7:41:08 AM
Comment:
^(([a-zA-Z]:)|(\\{2}[^\/\\:*?"<>|]+))(\\([^\/\\:*?"<>|]+))*(\\)?$


Title: A little improvement over Mouhcine's version
Name: Razvan
Date: 3/2/2011 7:38:53 AM
Comment:
^(([a-zA-Z]:)|(\\{2}[^\/\\:*?"<>|]+))(\\([^\/\\:*?"<>|]+))*(\\)?$


Title: Folder Path Regular Expression
Name: Mouhcine
Date: 3/11/2010 4:42:43 PM
Comment:
^(([a-zA-Z]:)|(\\{2}[^\/\\:*?"<>|]+))(\\([^\/\\:*?"<>|]*))*(\\)?$


Title: Folder path (local + network)
Name: Mahender
Date: 7/23/2008 3:19:55 AM
Comment:
^(((\\\\([^\\/:\*\?"\|<>\. ]+))|([a-zA-Z]:\\))(([^\\/:\*\?"\|<>\. ]*)([\\]*))*)$ c# @"^(((\\\\([^\\/:\*\?""\|<>\. ]+))|([a-zA-Z]:\\))(([^\\/:\*\?""\|<>\. ]*)([\\]*))*)$"


Title: Re: Capture specific name
Name: Michael Ash
Date: 11/11/2004 1:19:54 PM
Comment:
^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\\(\d{22}\.moc)$ As noted before http://www.regexlib.com/REDetails.aspx?regexp_id=800 is a better directory regex


Title: Capture specific name
Name: Junior
Date: 11/10/2004 12:46:32 PM
Comment:
I modifiyed the expression, because iam trying to validate the path C:\Documents and Settings\Junior\house\9993000000003310100478.moc But i need to validate the name of the archive have 22 integer and moc extension. But i just can validate 21 postions. Can you help me? ^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+([0-9]{21}.moc)$


Title: Re: special chars are not accounted for
Name: Michael Ash
Date: 10/20/2004 1:29:02 PM
Comment:
Use http://www.regexlib.com/REDetails.aspx?regexp_id=800 instead


Title: special chars are not accounted for
Name: Vladimir
Date: 10/18/2004 4:36:16 PM
Comment:
the path can contain special char like "&" in them. There is a set of illegal chars, though ( \/:?"<>| ). This accounts for special chars but I cannot get the exlusion for the illegals to work, though, ^(([a-zA-Z]:)|(\\{2}\w+))(\\((\w|\W)[(\w|\W .]*(\w|\W)))*(\\)$


Title: Folder Path Regular Expression
Name: Leny Paul
Date: 9/30/2004 12:56:46 AM
Comment:
I have modified your Regular Expression, with this one for periods in folder names ( Periods in Directories Invalidate) ^(([a-zA-Z]:)|(\\{2}\w+))(\\(\w[\w .]*\w))*(\\)$


Title: Periods in Directories Invalidate
Name: Geoff
Date: 7/26/2004 10:32:02 PM
Comment:
Thanks a lot! I appreciate it.


Title: Re: Periods in Directories Invalidate
Name: Michael Ash
Date: 7/26/2004 1:57:50 AM
Comment:
Use http://www.regexlib.com/REDetails.aspx?regexp_id=800 instead


Title: Periods in Directories Invalidate
Name: geoff
Date: 7/22/2004 6:17:07 PM
Comment:
This works: c:\Holidays\1225\christmas.txt this doesnt: c:\Holidays\12.25\christmas.txt Windows allows periods in Directory names. How can this be added?


Title: Folder Path Regular Expression
Name: Ahmed
Date: 7/1/2004 2:26:24 AM
Comment:
Check this One As well I want that these strings must be allowed c:\, c:\Program Files\, \\ahmed\,\\ahmed\Program files\,C:\program files\C booksand I have modified your Regular Expression, with this one ^(([a-zA-Z]:)|(\\{2}\w+))(\\(\w[\w ]*\w))*(\\)$


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