strsplit
Tokenizes the string s with the given delimiter delim.
Syntax
R = strsplit(s)
R = strsplit(s, delim)
R = strsplit(s, delim, 'collapsedelimiters', 'value')
Inputs
- s
- String to be split.
- delim (optional)
- Delimiter. Whitespace is the default delimiter.
- 'collapsedelimiters', value (optional)
- Name-value pair for specifying output contents. Valid options for value are true or false. The default option if value is not specified is true.
Outputs
- R
- Type: cell
Examples
R = strsplit('string1 string2 string3')
R =
{
[1,1] string1
[1,2] string2
[1,3] string3
}
R = strsplit('Split this string at the letter t', {' ', 't'})
R =
{
[1,1] Spli
[1,2] his
[1,3] s
[1,4] ring
[1,5] a
[1,6] he
[1,7] le
[1,8] er
[1,9]
}
R = strsplit('Split this string at the letter t', {' ', 't'}, 'collapsedelimiters', false)
R =
{
[1,1] Spli
[1,2]
[1,3]
[1,4] his
[1,5] s
[1,6] ring
[1,7] a
[1,8]
[1,9]
[1,10] he
[1,11] le
[1,12]
[1,13] er
[1,14]
[1,15]
}