It has been some time since I have posted, but I figured this one quick function for extracting a file extension was worth a quick post.
Problem:
You are dealing with files and want a quick way to extract the files extension.
Solution:
A simple function that will return back you to the extension of any file with or without a full path reference preceding it is this:
function getFileExtention(str:String):String{
return str.substring(str.lastIndexOf(".") + 1, str.length);
}
NOTE: This will not account for URLs that have GET parameters on the end of them. To do this, Google search getting file extension using regexp or regular expressions.
I hope this helps someone who is looking for a quick solution online. Good luck.