- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Pattern Title
^([a-zA-Z]\:)(\\[^\\/:*?<>"|]*(?<![ ]))*(\.[a-zA-Z]{2,6})$
Matches filenames. UPDATED on 1st Jan 2004.
C:\di___r\fi_sysle.txt | c:\dir\filename.txt
Author Rating: Not yet rated. Darren Neimke
Your Rating
Bad Good

Enter New 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: does not match
Name: max
Date: 3/1/2005 3:08:29 AM
i wanted to find simple files like "index.php" oder "test.txt" but it fails: Warning: preg_match_all() [function.preg-match-all]: Unknown modifier '\' in xxx on line yyy

Title: C:\SDF\ SDF.TXT
Name: xxc@china
Date: 9/8/2004 4:28:25 AM
C:\SDF\ SDF.TXT Will match. But infact,it's wrong. My English is not very well.

Title: Needs additional tests
Name: FWSGuy
Date: 7/6/2004 10:46:05 AM
The following entry produces a match using .Net: d:\\.ext

Title: Dear Bob Testa...
Name: Darren Neimke
Date: 6/15/2004 3:41:21 AM
...very eloquently put sir! I'm sorry that you were unable to read - down through the comments and find that, I have identified that the previous pattern was indeed "Bullshit" - as you put it. I've also offered another pattern (in that very same comment) which probably does work when using the javascript regex engine. Again, thankyou for your kind words of encouragement :P

Title: Bullshit
Name: Bob Testa
Date: 6/14/2004 11:08:04 AM
Doesn't work in Javascript... no sense in posting crap

Title: Thanks for the pick-up
Name: Darren Neimke
Date: 2/19/2004 8:47:43 PM
The negative lookbehind assertion won't be supported in js so, most likely I can get around that by implementing it as a negative lookahead and move it the front the 2nd group; like so: ^([a-zA-Z]\:)(\\(?!=[ ])[^\\/:*?<>"|]*)*(\.[a-zA-Z]{2,6})$

Title: Syntax Error when testing in Javascript
Name: ChrisK
Date: 2/19/2004 8:07:54 PM
Select Javascript and test the expression. Returns a syntax error.

Title: Different Idiom
Name: Darren Neimke
Date: 12/31/2003 6:23:59 PM
Thanks OracleGuy! I've altered the pattern to allow for spaces (and other characters in accordance with the WinXP operating system). You can read about the changes that I made here:

Title: Directories with spaces fail
Name: OracleGuy
Date: 12/30/2003 1:21:52 AM
If there is a space in the directory name, the pattern returns a non match. Fixing that would make this pattern quite valuable.

Copyright © 2001-2018, | ASP.NET Tutorials