strip

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

Parameters

str Range

string or random access range of characters

Return Value

Type: auto

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

Examples

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

See Also

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

Meta