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
stris a string scalar or character vector, thennewStris anN-by-1string array or cell array of character vectors, whereNis the number of substrings.If
stris anM-by-1string array or cell array, thennewStris anM-by-Narray.If
stris a1-by-Mstring array or cell array, thennewStris an1-by-M-by-Narray.
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