extension

extension
(
R
)
()
if (
isRandomAccessRange!R &&
hasSlicing!R
&&
isSomeChar!(ElementType!R)
||
is(StringTypeOf!R)
)

Return Value

Type: auto

The extension part of a file name, including the dot.

If there is no extension, null is returned.

Examples

import std.range : empty;
assert(extension("file").empty);
assert(extension("file.") == ".");
assert(extension("file.ext"w) == ".ext");
assert(extension("file.ext1.ext2"d) == ".ext2");
assert(extension(".foo".dup).empty);
assert(extension(".foo.ext"w.dup) == ".ext");

static assert(extension("file").empty);
static assert(extension("file.ext") == ".ext");

Meta