string.splitlines
string: newstr = splitlines (str)
Split string array at newline characters.
newstr = splitlines (str) divides each element of
str at its newline characters and returns the lines as a string
array. The recognized newline characters are the line feed, the carriage
return, a carriage return followed by a line feed (treated as a single
boundary), the vertical tab, the form feed, and the Unicode next-line
(U+0085), line-separator (U+2028), and paragraph-separator
(U+2029) characters.
The lines are laid out along a new dimension exactly as for split:
a string scalar with n lines yields an nx1 array, and
an Mx1 column yields an Mxn array. Every element of
str must contain the same number of newlines. Missing values in
str are preserved and count as a single line.
Source Code: string
splitlines breaks a string at its newline characters into one element per line.
s = string (sprintf ('first\nsecond\nthird'))
s =
string
"first
second
third"
splitlines (s)
ans =
3x1 string array
"first"
"second"
"third"