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.splitLines

Split s into an array of lines according to the unicode standard using '\r', '\n', "\r\n", std.uni.lineSep, std.uni.paraSep, U+0085 (NEL), '\v' and '\f' as delimiters. If keepTerm is set to KeepTerminator.yes, then the delimiter is included in the strings returned.

Does not throw on invalid UTF; such is simply passed unchanged to the output.

Allocates memory; use lineSplitter for an alternative that does not.

Adheres to Unicode 7.0.

Prototype

S[] splitLines(S)(
  S s,
  KeepTerminator keepTerm = KeepTerminator.no
) pure @safe
if (isSomeString!S);

Parameters

NameDescription
s a string of chars, wchars, or dchars
keepTerm whether delimiter is included or not in the results

Returns

array of strings, each element is a line that is a slice of s

See Also

lineSplitter std.algorithm.splitter std.regex.splitter

Authors

Walter Bright, Andrei Alexandrescu, and Jonathan M Davis

License

Boost License 1.0.

Comments