Perl-Python-a-Day: split a file full path
Xah Lee
xah at xahlee.org
Mon Oct 17 17:33:30 EDT 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:
http://xahlee.org/perl-python/split_fullpath.html
namely:
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
xah at xahlee.org
∑ http://xahlee.org/
More information about the Python-list
mailing list