Better path/filename regex?

  • Thread starter Thread starter sherifffruitfly
  • Start date Start date
S

sherifffruitfly

This is the best I could quickly come up with:

(?<path>[a-z]:\\(?:[^\\]+\\)+)(?<filename>.+?\.[\S]+)

It's certainly too permissive, but I don't *think* it leaves any valid
ones out (I'm sure a counterexample is only seconds away... :) ).


Many thanks if you have a better one...

cdj
 
cdj,

Why use a regular expression for this? Why not use the static methods
on the Path class in the System.IO namespace to do what you want?
 
The built-in File and Path classes would help you out immensely. They
already have functionality to do this.
 
cdj,

Why use a regular expression for this? Why not use the static methods
on the Path class in the System.IO namespace to do what you want?

Because I didn't know they had path/filename strippers. For some
reason I thought a .net path was what most people called a path
+filename. I'll totally look again tho - thanks!

cdj
 
Back
Top