"How do I make it so that only HAIR is the delimiter and not H, A, I, or R?"
You can't do that with strtok. The simplest is to regexp with the 'split' option:
>> regexp('Hello World HAIR xyz HAIRdo', 'HAIR', 'split')
ans =
1×3 cell array
{'Hello World '} {' xyz '} {'do'}
Note: read the documentation of regexp as some characters such as .+- have special meaning.
2 Comments
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/513173-strtok-is-only-using-the-first-character-of-my-delimiter-instead-of-the-full-character-vector#comment_815955
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/513173-strtok-is-only-using-the-first-character-of-my-delimiter-instead-of-the-full-character-vector#comment_815955
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/513173-strtok-is-only-using-the-first-character-of-my-delimiter-instead-of-the-full-character-vector#comment_815960
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/513173-strtok-is-only-using-the-first-character-of-my-delimiter-instead-of-the-full-character-vector#comment_815960
Sign in to comment.