string.file_extension

Returns the file extension from a filesystem path.

Usage

string.file_extension(path)

Arguments

Name Type Description
path string A filesystem path.

Returns

Name Type Description
extension string File extension without the ., or nil.

Examples

local path = "assets/characters/tarkus.png";
print(path:file_extension()); -- Prints "png"
local path = "assets/characters";
print(path:file_extension()); -- Prints "nil"

This site uses Just the Docs, a documentation theme for Jekyll.