Logo

Programming-Idioms

History of Idiom 151 > diff from v9 to v10

Edit summary for version 10 by programming-idioms.org:
[D] It's about folder separator, not about whitespace

Version 9

2017-07-26, 09:34:58

Version 10

2017-07-29, 18:26:12

Idiom #151 Remove string trailing path separator

Remove last character from string p, if this character is the file path separator of current platform.

Note that this also transforms unix root path "/" into empty string!

Idiom #151 Remove string trailing path separator

Remove last character from string p, if this character is the file path separator of current platform.

Note that this also transforms unix root path "/" into empty string!

Imports
import std.string,
import std.ascii;
Imports
import std.string,
import std.path;
Code
p = p.chomp(newLine);
Code
p = p.chomp(dirSeparator);
Comments bubble
By default chomp removes all line separator, regardless of the platform so we specify a platform-specific value.
Doc URL
https://dlang.org/phobos/std_string.html#.chomp
Doc URL
https://dlang.org/phobos/std_string.html#.chomp