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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(\..+)?$)[^\x00-\x1f\\?*:\";|/]+$
Description
Checks for a valid windows file name (Must be used with the case-insensitive option Checks that the file has at lease one char, does not contain any invalid characters and does not have a reserved word as a file name. "If you see a " in the regex replace it with a " character"
Matches
test.txt | test.jpg.txt | a&b c.bmp
Non-Matches
CON | .pdf | test:2.pdf
Author Rating: Not yet rated. Andre Van Der Merwe
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: Corrections
Name: vic
Date: 2/23/2004 10:49:08 AM
Comment:
Worked great or me, with minor modifications. 1. The original expression disallowed a semicolon, but Windows allows it in file names. 2. Signs "<" and ">" should not be allowed. Here is the corrected expression, I don't know if the browser will display it correctly. If not - mofify the end of the original posted expression (starting with the "?"), to this: ?*:\"><|/]+$ Corrected expression: ^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(\..+)?$)[^\x00-\x1f\\?*:\"><|/]+$


Title: Another failure...
Name: Mark McDonald
Date: 7/14/2003 11:15:41 PM
Comment:
filena~1.doc also fails.


Title: Mr.
Name: Pedram Nimreezi
Date: 5/5/2003 1:37:30 AM
Comment:
file.txt is a false negative.


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