Line to strip both the right and left side of.
Character or string of characters to strip away.
The passed line, stripped of surrounding passed characters.
{ immutable line = " abc "; immutable stripped_ = line.stripped(' '); assert((stripped_ == "abc"), stripped_); } { immutable line = "!!!"; immutable stripped_ = line.stripped('!'); assert((stripped_ == ""), stripped_); } { immutable line = ""; immutable stripped_ = line.stripped('_'); assert((stripped_ == ""), stripped_); } { immutable line = "abc"; immutable stripped_ = line.stripped('\t'); assert((stripped_ == "abc"), stripped_); } { immutable line = " \r\n abc\r\n\r\n "; immutable stripped_ = line.stripped(' '); assert((stripped_ == "\r\n abc\r\n\r\n"), stripped_); } { immutable line = " abc "; immutable stripped_ = line.stripped(" \t"); assert((stripped_ == "abc"), stripped_); } { immutable line = "!,!!"; immutable stripped_ = line.stripped("!,"); assert((stripped_ == ""), stripped_); } { immutable line = ""; immutable stripped_ = line.stripped("_"); assert((stripped_ == ""), stripped_); } { immutable line = "abc"; immutable stripped_ = line.stripped("\t\r\n"); assert((stripped_ == "abc"), stripped_); } { immutable line = " \r\n abc\r\n\r\n "; immutable stripped_ = line.stripped(" _"); assert((stripped_ == "\r\n abc\r\n\r\n"), stripped_); }
Returns a slice of the passed string with any preceding or trailing passed characters sliced off. Implementation template capable of handling both individual characters and strings of tokens to strip.
It merely calls both strippedLeft and strippedRight. As such it duplicates std.string.strip, which we can no longer trust not to assert on unexpected input.