Life as a hoster, My linux desktop, PHP
How to get a file extension
How to get a file extension in PHP:
$ext = pathinfo($file_name, PATHINFO_EXTENSION);
How to get a file extension in Perl:
my $ext = ($file_name =~ m/([^.]+)$/)[0];
How to get a file extension in Ruby:
ext = File.extname(file_name)
How to get a file extension in Bash:
ext=${file_name##*.}
name=${file_name%.*}
How to get a file extension in Python (thanks to Jensen):
import os ext = os.path.splitext(file_name)[1]
—
Got more? Please post a comment.
31 May 2008 Arnold Daniels 25 comments




