Extract file extension
ts
function ExtractExt(fileName: string): string;Returns the file extension (including the dot) from any file name or path. If the file has no extension, returns an empty string.
Parameters
| Name | Type | Description |
|---|---|---|
| fileName | string | File name or path to extract from. |
Returns
A string containing the file extension, including the dot (e.g., ".txt").
NOTE
If the file has no extension, an empty string is returned. For files with multiple dots, only the last segment is considered the extension.
Example
ts
var res = ExtractExt('/docs/sheets/budget.xlsx');
// res will be ".xlsx"