View source code Display the source code in std/path.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

Function std.path.extension

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

If there is no extension, null is returned.

Prototype

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

Examples

assert (extension("file").empty);
assert (extension("file.ext")       == ".ext");
assert (extension("file.ext1.ext2") == ".ext2");
assert (extension("file.")          == ".");
assert (extension(".file").empty);
assert (extension(".file.ext")      == ".ext");

Authors

Lars Tandle Kyllingstad, Walter Bright, Grzegorz Adam Hankiewicz, Thomas Kühne, Andrei Alexandrescu

License

Boost License 1.0

Comments