Perl-Python-a-Day: split a file full path

Xah Lee xah at
Mon Oct 17 23:33:30 CEST 2005

Xah Lee wrote:
> > In Perl, spliting a full path into parts is done like this:

Dr.Ruud wrote:
> And then follows Perl-code that only works with an optional .html
> "extension",

Thanks for the note. I've corrected it here:

Note: the second argument to fileparse() is a list of regex. In
particular, you need to escape the dot. Normally, one gives it a value
such as ('\.html', '\.HTML', '\.jpg', '\.JPG'). Yes, it is case
sensitive. If you want to match any extension (that is, the string
after the last dot), use ('\.[^.]+$').

 xah at xahlee.org

More information about the Python-list mailing list