split
Split strings at delimiters
Syntax
Description
divides newStr
= split(str
)str
at whitespace characters and returns the result as
the output array newStr
. The input array str
can be a string array, character vector, or cell array of character vectors. If
str
is a string array, then so is newStr
.
Otherwise, newStr
is a cell array of character vectors.
newStr
does not include the whitespace characters from
str
.
If str
is a string array or cell array of character vectors,
and has multiple elements, then each element must be divisible into the same number
of substrings.
If
str
is a string scalar or character vector, thennewStr
is anN
-by-1
string array or cell array of character vectors, whereN
is the number of substrings.If
str
is anM
-by-1
string array or cell array, thennewStr
is anM
-by-N
array.If
str
is a1
-by-M
string array or cell array, thennewStr
is an1
-by-M
-by-N
array.
For a string array or cell array of any size, split
orients the
N
substrings along the first trailing dimension with a size
of 1
.
If the number of substrings is not the same for every element of
str
, then call split
in a
for
-loop to divide the elements of str
one
at a time.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced in R2016b
See Also
join
| extract
| string
| newline
| compose
| splitlines
| pattern
| lettersPattern
| count