std.array.split - multiple declarations
- Function split
- Function split
Function split
Eagerly split the string into an sarray of words, using whitespace as
delimiter. Runs of whitespace are merged together (no empty words are produced).
@safe, pure and CTFE-able.
Prototype
S[] split(S)( S s ) pure @safe if (isSomeString!S);
See Also
std.algorithm.iteration.splitter for a version that splits using any
separator.
std.regex.splitter for a version that splits using a regular
expression defined separator.
Example
assert(split("hello world") == ["hello","world"]);
assert(split("192.168.0.1", ".") == ["192", "168", "0", "1"]);
auto a = split([1, 2, 3, 4, 5, 1, 2, 3, 4, 5], [2, 3]);
assert(a == [[1], [4, 5, 1], [4, 5]]);
Function split
Eagerly splits into an rangearray, using as the delimiter.
sep
The range must be a
forward range.
The separator can be a value of the same type as the elements in
or it can be another forward range.
range
Prototypes
auto split(Range, Separator)( Range range, Separator sep ) if (isForwardRange!Range && is(typeof(ElementType!Range.init == Separator.init))); auto split(Range, Separator)( Range range, Separator sep ) if (isForwardRange!Range && isForwardRange!Separator && is(typeof(ElementType!Range.init == ElementType!Separator.init))); auto split(alias isTerminator, Range)( Range range ) if (isForwardRange!Range && is(typeof(unaryFun!isTerminator(range.front))));
Examples
If is a rangestring, can be a sepchar or another
string. The return type will be an array of strings. If is
an rangeint array, can be an sepint or another int array.
The return type will be an array of int arrays.
Parameters
| Name | Description |
|---|---|
| range | a forward range. |
| sep | a value of the same type as the elements of or another
forward range. |
Returns
See Also
std.algorithm.iteration.splitter for the lazy version of this
function.
Authors
Andrei Alexandrescu and Jonathan M Davis