strsplit
Split string or character vector at specified delimiter
Syntax
Description
Note
split
is recommended
over strsplit
because it provides greater flexibility
and allows vectorization. For additional information, see Alternative Functionality.
splits C
= strsplit(str
)str
at whitespace into C
. A
whitespace character is equivalent to any sequence in the set {'
','\f','\n','\r','\t','\v'}
.
If str
has consecutive whitespace characters, then
strsplit
treats them as one whitespace.
splits C
= strsplit(str
,delimiter
)str
at
the delimiters specified by delimiter
.
If str
has consecutive delimiters, with no other characters
between them, then strsplit
treats them as one delimiter.
For example, both strsplit('Hello,world',',')
and
strsplit('Hello,,,world',',')
return the same
output.
specifies additional delimiter options using one or more name-value pair
arguments. For example, to treat consecutive delimiters as separate delimiters,
you can specify C
= strsplit(str
,delimiter
,Name,Value
)'CollapseDelimiters',false
.
Examples
Input Arguments
Output Arguments
Alternative Functionality
Update code that makes use of strsplit
to use split
instead. The default orientation for split
is
by column. For example:
Not Recommended | Recommended |
---|---|
str = strsplit("1 2 3") str = 1×3 string array "1" "2" "3" |
str = split("1 2 3") str = 3×1 string array "1" "2" "3" |
Extended Capabilities
Version History
Introduced in R2013a