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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details Parse & Extract Filename Parts
Expression
^(.*?)([^/\\]*?)(\.[^/\\.]*)?$
Description
Simple (non-validating) match with numbered group captures that extracts parts of a filename into $1 = folder path, $2 = filename w/o extension, $3 = extension. Should work on Windows, OS X, and Unix/Linux, but not on OS 9 and OSs with folder separators other than slashes (either direction). Tested only on .NET RE engine.
Matches
test | test.txt | C:\test | C:\test.txt | C:\test.txt\testing.txt | C:\folder\test | C:\folder\test.txt.txt | C:\folder\test.txt.txt\testing.txt | /usr/test | /usr/test.txt | /usr/test.txt/testing.pdf
Non-Matches
N/A (some captures may end up being blank in the event of a relative path or no file extension)
Author Rating: The rating for this expression. Matthew
   Displaying page 1 of 1 pages; Items 1 to 1

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