strtok
Splits the string s at the given delimiter delim and returns a cell array whose elements are the substrings of string s.
Syntax
R = strtok(s)
R = strtok(s, delim)
[R, Rem] = strtok(s, delim)
Inputs
- s
- Type: string
- delim (optional)
- Delimiter. Whitespace is the default delimiter.
Outputs
- R
- Tokenized result.
- Rem (optional)
- Remainder after the input string is tokenized.
Examples
R = strtok(' Tokenize this string')
R = Tokenize
R = strtok('12345 + 678 - 9', '+-')
R = 12345
[R, Rem] = strtok('45 * 12345 + 678 - 9', '+-')
R = 45 * 12345
Rem = + 678 - 9
Comments
If there is no delimiter delim specified, whitespace is used as the default delimiter. If a remainder Rem is specified, Rem will contain the remainder of the string s along with the first character of the delimiter delim, if specified.