The OpenD Programming Language

stripRight

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

  1. auto stripRight(Range str)
    stripRight
    (
    Range
    )
    (
    Range str
    )
  2. auto stripRight(Range str, const(Char)[] chars)

Parameters

str Range

string or random access range of characters

Return Value

Type: auto

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

Examples

import std.uni : lineSep, paraSep;
assert(stripRight("     hello world     ") ==
       "     hello world");
assert(stripRight("\n\t\v\rhello world\n\t\v\r") ==
       "\n\t\v\rhello world");
assert(stripRight("hello world") ==
       "hello world");
assert(stripRight([lineSep] ~ "hello world" ~ lineSep) ==
       [lineSep] ~ "hello world");
assert(stripRight([paraSep] ~ "hello world" ~ paraSep) ==
       [paraSep] ~ "hello world");

See Also

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

Meta