View source code
Display the source code in std/string.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.string.strip
Strips both leading and trailing whitespace (as defined by
std.uni.isWhite
).
Prototype
auto strip(Range)( Range str ) if (isSomeString!Range || isRandomAccessRange!Range && hasLength!Range && hasSlicing!Range && isSomeChar!(ElementEncodingType!Range));
Parameters
Name | Description |
---|---|
str | string or random access range of characters |
Returns
slice of
stripped of leading and trailing whitespace.
str
Example
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");
Authors
Walter Bright, Andrei Alexandrescu, and Jonathan M Davis