phobos/changelog/std-string-strip.dd
Aravinda VK 2346990c09 Fix issue 13632: Enhancement to std.string.strip
Added second argument similar to Python `str.strip`

Second argument accepts a string of characters to strip and
strips only those characters.

Examples:

    "xyzhello".stripLeft("xyz") == "hello"
    "helloxy ".stripRight("xy ") == "hello"
    "xhellox".strip("x") == "hello"

Signed-off-by: Aravinda VK <mail@aravindavk.in>
2018-01-31 09:42:45 +05:30

14 lines
497 B
Text

`std.string.strip` now accepts a string of characters to be stripped
New overload functions of $(REF strip, std, string),
$(REF stripLeft, std, string) and
$(REF stripRight, std, string) accepts a string of characters to be
stripped instead of stripping only whitespace.
---
import std.string: stripLeft, stripRight, strip;
assert(stripLeft("www.dlang.org", "w.") == "dlang.org");
assert(stripRight("dlang.org/", "/") == "dlang.org");
assert(strip("www.dlang.org/", "w./") == "dlang.org");
---