The OpenD Programming Language

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.

@safe pure
C[][]
splitLines
(
C
)
(
C[] s
,
KeepTerminator keepTerm = No.keepTerminator
)

Parameters

s C[]

a string of chars, wchars, or dchars, or any custom type that casts to a string type

keepTerm KeepTerminator

whether delimiter is included or not in the results

Return Value

Type: C[][]

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

Examples

string s = "Hello\nmy\rname\nis";
assert(splitLines(s) == ["Hello", "my", "name", "is"]);

See Also

Meta