Skip to content

Instantly share code, notes, and snippets.

@nivrith
Created November 4, 2019 03:25
Show Gist options
  • Save nivrith/8489ed0b6c41aed37a6c02f904d4b96d to your computer and use it in GitHub Desktop.
Save nivrith/8489ed0b6c41aed37a6c02f904d4b96d to your computer and use it in GitHub Desktop.
Get File extension from filename
const fileExt = filename => {
const ext = f => (/[.]/.exec(f)) ? /[^.]+$/.exec(f) : RegExp(f).exec(f);
const resultExp = ext(filename);
return resultExp ? resultExp[0] : filename;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment