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.stripExtension

Remove extension from path.

Prototype

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

Parameters

NameDescription
path string or range to be sliced

Returns

slice of path with the extension (if any) stripped off

Examples

assert (stripExtension("file")           == "file");
assert (stripExtension("file.ext")       == "file");
assert (stripExtension("file.ext1.ext2") == "file.ext1");
assert (stripExtension("file.")          == "file");
assert (stripExtension(".file")          == ".file");
assert (stripExtension(".file.ext")      == ".file");
assert (stripExtension("dir/file.ext")   == "dir/file");

Authors

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

License

Boost License 1.0

Comments