Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Split strings in string array

`newStr = split(str)`

`newStr = split(str,delimiter)`

`newStr = split(str,delimiter,dim)`

```
[newStr,matches]
= split(___)
```

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, a character vector, or a 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`

contains multiple elements, then each element must be
divisible into the same number of substrings.

If

`str`

is a string scalar or character vector, then`newStr`

is an`N`

-by-`1`

string array or cell array of character vectors, where`N`

is the number of substrings.If

`str`

is an`M`

-by-`1`

string array or cell array, then`newStr`

is an`M`

-by-`N`

array.If

`str`

is a`1`

-by-`M`

string array or cell array, then`newStr`

is an`1`

-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.

Was this topic helpful?