Is there a (default) Matlab function that behaves similar to the java method split(delimiter), where you can tokenize a string based on an arbritary delimiter?
There is a built-in function called textscan
that's capable of this:
>> C = textscan('I like stack overflow', '%s', 'delimiter', 'o');
>> C = C{1}
C =
'I like stack '
'verfl'
'w'
Here are more than one ways to split a string. One as Rody Oldenhuis has just mentioned, and here are some others:
1> Using the function regexp
:
>> str = 'Good good study Day day up';
>> regexp(str,'\s','split')
ans =
'Good' 'good' 'study' 'Day' 'day' 'up'
>>
2> Using the function strread
:
>> str = 'Section 4, Page 7, Line 26';
>> strread(str, '%s', 'delimiter', ',')
ans =
'Section 4'
'Page 7'
'Line 26'
>>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With