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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Windows Filename
Expression
^[^ \\/:*?""<>|]+([ ]+[^ \\/:*?""<>|]+)*$
Description
This was written for C# and so you should just be able to drop it into your C# program. Although you can create files with leading and trailing spaces through non-GUI means, the Windows GUI itself eats those spaces if you try to rename the file. For this reason I made the decision to consider file names with leading and trailing spaces invalid. This has been tested against large data sets.
Matches
bla, file.txt, !@#$
Non-Matches
bla , file:txt, /\*?
Author Rating: Not yet rated. 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

Title: This isn't even close
Name: KRowe
Date: 10/11/2015 11:56:34 AM
Comment:
Not only is bla valid but you are missing a ton of edge cases. See http://stackoverflow.com/a/62888/932549 for a more detailed discussion.


Title: armageddon-,&1
Name: armageddon-,&1
Date: 5/15/2014 5:42:38 PM
Comment:
asdf


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