Skip to content

Instantly share code, notes, and snippets.

@mishin
Created October 5, 2013 23:15
Show Gist options
  • Save mishin/6847253 to your computer and use it in GitHub Desktop.
Save mishin/6847253 to your computer and use it in GitHub Desktop.
function getFileExtension(i) {
// i will be a string, but it may not have a file extension.
// return the file extension (with no period) if it has one, otherwise false
var pat1= /(.*\.)(\w+)/i;
if (i.match(pat1)){
//alert( i.replace( /(.*\.)(\w+)/i ,'$2') ) ;
var out=i.replace( pat1 ,'$2') ;
alert(out);
return out;
}else{
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment