Here's a quick Javascript function that will parse the filename from a path using regex. It looks for any letter or digit, hyphen, or underscore followed by a dot (.) followed by a letters or numbers for the extension.
function getFileName(path) {
return path.match(/[-_\w]+[.][\w]+$/i)[0];
}
Wednesday, August 12, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment