//by MoreWindows (http://blog.)
function GetExtensionFileName(pathfilename)
{
var reg = /(\\+)/g;
var pfn = pathfilename.replace(reg, "#");
var arrpfn = pfn.split("#");
var fn = arrpfn[arrpfn.length - 1];
var arrfn = fn.split(".");
return arrfn[arrfn.length - 1];
}
function Test()
{
var filePath="D:\\Program Files\\Notepad++\\Notepad++.exe";
alert(GetExtensionFileName(filePath));
}
<input type="button" value="Test" onclick="Test()" />
参考:http://blog.