The OpenD Programming Language

strip

Strips both leading and trailing whitespace (as defined by std.uni.isWhite) or as specified in the second argument.

  1. auto strip(Range str)
  2. auto strip(Range str, const(Char)[] chars)
  3. auto strip(Range str, const(Char)[] leftChars, const(Char)[] rightChars)
    strip
    (
    Range
    Char
    )
    (
    Range str
    ,
    const(Char)[] leftChars
    ,
    const(Char)[] rightChars
    )
    if (
    (
    (
    isBidirectionalRange!Range &&
    )
    ||
    )
    &&
    )

Parameters

str Range

string or random access range of characters

leftChars const(Char)[]

string of leading characters to be stripped

rightChars const(Char)[]

string of trailing characters to be stripped

Return Value

Type: auto

slice of str stripped of leading and trailing whitespace or characters as specified in the second argument.

Examples

assert(strip("xxhelloyy", "x", "y") == "hello");
assert(strip("   xyxyhello worldxyxyzz    ", "xy ", "xyz ") ==
       "hello world");
assert(strip("\u2020hello\u2028"w, "\u2020"w, "\u2028"w) == "hello"w);
assert(strip("\U00010001hello\U00010002"d, "\U00010001"d, "\U00010002"d) ==
       "hello"d);
assert(strip(" hello ", "", "") == " hello ");
assert(strip("     hello world     ", "x") ==
       "     hello world     ");
assert(strip("     hello world     ", " ") ==
       "hello world");
assert(strip("   xyxyhello worldxyxy     ", "xy ") ==
       "hello world");
assert(strip("\u2020hello\u2020"w, "\u2020"w) == "hello"w);
assert(strip("\U00010001hello\U00010001"d, "\U00010001"d) == "hello"d);
assert(strip(" hello ", "") == " hello ");

See Also

Generic stripping on ranges: std.algorithm.mutation._strip

Meta